« first day (878 days earlier)      last day (657 days later) » 

ngn
ngn
07:03
thanks to @bubbler's nomination, k is now:
2
6
Q: Language of the Month for August 2021: K

BubblerIn accordance with our meta agreement, since one candidate received more votes than the others, we have a new featured language! Throughout August 2021, our Language of the Month will be: K What's a Language of the Month? See the meta post for nominations. In short, during August, those who wis...

4
@Bubbler i can't contribute much time but can i offer my rep for you to spend as you see fit? it should be enough for at least 500/day in bounties
Is there a simple way to map a function over a list?
'
{}'<list>
At least, that's how I'm doing it
yep that's right
if you're using arithmetic ops only, you can do {}@ as well
07:17
Here's the start of my attempt at a horribly cursed fizzbuzz: {("Fizz";"Buzz")*(0=(3!x;5!x))}'1+!100
So is ; syntax sugar for newlines?
no
In strings I mean
> Mixed-type lists are enclosed in () and each element should be separated by a semicolon:

(1 2 3;"food";`b)
; and newline both work as statement separators, yes
07:18
oh nevermind kekw
I is using that too
so is {} a dfn?
Welcome @PyGamer0
@PyGamer0 yes, very similar
It's like JS but less cursed
@PyGamer0 k has variadic dfns though
x,y,z are the default first, second and third arguments
07:19
@Razetime so multiple arguments can be passed?
@PyGamer0 yes, func[arg1;arg2;arg3]
there are 3 main ways to apply a function
func @ arg applies a single argument to a function
@Razetime how to keep only truthy items in an array?
func[arg1;arg2;...] can apply any number of arguments, called an M-expression
@lyxal {x}#array
where # is used as filter
that...doesn't seem to work
and the third way is dot-apply: func.array
ok how does the fibonacci seq program look like?
there's a lot of ways to do fibonacci
give it a try first and I'll tell you how to improve it
@lyxal so this also works like APL's filter
I barely knew what I was doing with my APL fizzbuzz
so what makes you think I know how APL's filter works?
ok so lemme teach that then
what happens when you repeat a thing 0 times
empty
nothing
nil
07:25
how do i give names for functions?
it ceases to exist
@Razetime that's what i said
@PyGamer0 functions and vars are declared using <name>:<value>
@lyxal yes, but there's no nil value assigned is what I'm getting at
it's just removed
oh
so a filter also works as a replicate
so you need {~~x}#array
07:26
very nice
uuuh if statements?
$[]??
@PyGamer0 where we are going, we don't need if statements ;)
@PyGamer0 yes, that's the one
you'll rarely need if statements unless recursion
@Razetime how do i define the condition and the body
f:{$[x=0;1]}
is that right?
erm, why is () considered truthy when logically or'ing?
wait better question
why is () considered greater than something like 3?
how do I make ()|3 or ()&3 return 3?
@Razetime ?!
07:38
@lyxal What you're seeing is vectorized max/min
an empty value is greater and less than 3?
oh right
it's vectorising over an empty list
You have a list on one side and a scalar on the other side. The scalar side is mapped to every item in the list
Yes
K doesn't have duck-typing-y falsiness, so you may need to think something entirely different to get what you want
@ngn Thanks for the offer, but I believe I can afford the LotM bounties myself.
@PyGamer0 Almost correct, but you need else branch too
As single line: {}`0:{$[1=#x;$-1#x;1;`c$1_x]}'{x,{~~x}#,/("Fizz";"Buzz")*0=(3;5)!'x}'1+!100
Nice job
@Bubbler how do i print the argument?
07:52
K will auto print return values
f:{$[x=0;1;f x-1]} so far
unless you terminate the line with a semicolon
1`0:x
@PyGamer0 yes, this is a correct function, now call it
@Razetime it always return 1
07:54
oh, it's a recursive program
nvm you're doing the wrong thing
@PyGamer0 you're missing one step
@Razetime what
yep, this is a factorial
what's the elementary operation in the factorial
@Razetime multiplication
you have no multiplication in your function
welcome @yiyus
f:{$[x=0;1;x*o x-1]} works
07:58
correct
there's a -2 bytes possible
can you find it?
08:21
f:{$[x=0;1;x*o x-1
? @Razetime ^
No, K isn't a golflang like Vyxal, so it doesn't have bracket autocompletion or something like that
sooo how?
08:45
hint: truthy and falsy values
Hi
Fiddling w/ stuff
hello
what's the stuff
How do you repeat a string?
n times? like Hello → HelloHello?
08:56
,/2#, comes to mind
How does that work and how do I use it?
just plop the string on the right
it makes a singleton array, repeats its elements n times, then joins the array
And the number on the left? Ok
no, no number on the left
you have to change the 2 to what number you need
08:58
as
Thanks
as a function: {,/x#,y}
or {(x*#y)#y}
Ok
Just warning you: I have four nested functions right now...
well, I can help out dw
just make sure your thing works
How do I get a single backslash in a string?
09:03
same as C
double backslash
Or is that just prettyprinting?
that's the prettyprinting
Gotcha
09:13
really, the pretty printing is done such that you can always paste returned values back into a K program
09:36
How do you join a list into a string without a separator?
ngn
ngn
@Bubbler the more bounties the merrier
for instance, i think there should be a BIG bounty for anyone who manages to outgolf @coltim at least once this month :D
@Ausername you can reshape atoms too: ,/n#," " -> n#" "
@ngn Thanks! I'll think about golfing it once it's working :p
ngn
ngn
@Ausername that newline after $[ looks suspicious
09:46
I know, newlines are statement separators
But it appears to be working
but it is sus
you do not want your code to be ejected
woot woot
Implementing it wasn't too hard - I basically copied my reference implementation :p
copying from different languages doesn't work too well in K
but you managed it, nice
now to improve it
09:58
I'll leave that to you guys.
(";"\x)";"\x
K is right to left
Oh cool
one more tip: "<char>" is a single character, not a string
so you can do n#" " instead of ,/n#," "
Oh ok
That be cool
characters are also integers in K
this means you can check equality with ascii values
10:02
Oh that's good
Can you do the same with the string repetition trick?
nope, chars are still a different type
you'll need to spend extra bytes casting it back
so "\\"=x can become 92=x
Ok
Doing all of that
{,/x}' can be just ,/'
likewise "/"=x can be 47=x
(k-1)=x becomes x=k-1 due to right to left
10:06
I actuallyhadthat onealready
One moment
a large part of good K programming, and in turn, golfy K programming is removing conditionals
,/k#,$[x=k-1;"_";" "]
there is a pattern here, can you spot it
The last one is a _, the rest are spaces
Oh I se
e
Una moment
you don't need a lot of ,/s there
{k#" "}'!k can be converted to (k;k)#" "
10:13
@Razetime I tried this
but it didn't work
ok lemme show
we have:
,/k#,$[x=k-1;"_";" "]
remove the ,/ and ,
k#$[x=k-1;"_";" "]
Yep
What now?
now, if x=k-1 is zero then we get an underscore
if it's 1 we get a space
Yeah
Oh indexing?
k#"_ "@x=k-1
10:15
Nice!
you can do this with most of the 2 branch conditionals
lemme add my golfs
Cool
That should get it down to sub 200
Or not
:)
Actually 197
ah ok
10:24
Since the f: isn't part of it
right?
Is there a flat array operator?
since the enormous if is basically checking x against a bunch of values
Because that could save a few more bytes
@Ausername flatten?
10:24
Yes
like,abitrary levels of nesting?
,// flattens till fixpoint
which would work
Just flattening one layer is fine
then ,/ is enough
you don't need to join on newlines
since 2d array is allowed as output
10:29
Oh yes
I allowed that
the io verb will insert newlines automatically for verification
184 because I also said input will only contain certain chars
ah removing the final condition
Actually removing the | condition 'cos it's a byte longer
10:42
175 By wrapping the code for \/ in another function
neat
For vectorised reverse, is there anything shorter than {|x}'?
' is an adverb
so you can just do |'
so #, _ and other verbs need functions
but adverbs can directly take primitive
oh, you need monadic |
so do |:'
10:52
Ok
And after a bit more stuff, 165
once pygamer's bounty is over I'll award
Ok
I think that's all the golfing I can do, at least for today.
11:14
@Ausername Impressive for the first day in K :D
 
2 hours later…
ngn
ngn
13:22
can anyone solve it in 64 bytes or fewer?
ngn
ngn
13:33
ooh, 58 actually :)
58?
holy
ngn
ngn
55 now (matching charcoal's score)
should i post it? or somehow try to bounty it per byte golfed?
hm, it has to have math
or i'm missing a primitive
ngn
ngn
@Razetime what math?
i would say it's mostly structural primitives
probably a base decode
ngn
ngn
13:47
no
oh, then it's the second reason lol
I've been thinking of it too
Will try next morning
ngn
ngn
@Bubbler ok, i'm not gonna post it now then
^ this comment requires revenge :)
i guess it does
but i can't really think of anything yet
too vim-pilled rn
i'm back on my native where itch. this is ~4-5x native speed {|\@[&*|v; -1_v:+\x; :; 1_!#x]}
@ngn it would be good if 0 :': was around the same speed as 0,-1_
ngn
ngn
14:09
@chrispsn yes, that's just a memmov and a store, but i need to improve my code for arithmetic in general to allow for ad-hoc optimizations like this
ah, at first I thought it would just be a form of github.com/JohnEarnest/ok/blob/gh-pages/ike/examples/…, but I suppose the nasty part is the padding
14:41
@ngn I've got 51 in BQN, but that's still kinda long considering it has actual matrix operations and a 2D raze
 
2 hours later…
ngn
ngn
16:27
@ngn s/memmov/memmove/
 
1 hour later…
ngn
ngn
17:31
@dzaima now i have 51 too
 
2 hours later…
19:31
Lol you guys are beating me 3x
and I completely forgot you can rename function inputs :p
It's actually quite similar to JS, but with more bulitins.
 
2 hours later…
21:19
@Razetime my money is on =i

« first day (878 days earlier)      last day (657 days later) »