Earlier quoted context omitted.
I'm not going to deny that learning any array language requires thinking slightly differently (as does any new paradigm), but really this example doesn't use anything particularly strange. {x#x{x,+/-2#x}/0 1} x x is the argument of an anonymous function {} , concat +/ plus reduce (sum) -2#x last two elements of x x f /0 1 applied x times to 0 1 x# take first x elements
It does have some strange things: - What's the scope of x? it appears to be the argument of two different anonymous functions. - Is / both apply and reduce? - So 'x f list' applies f to list x times. What if I use ',' instead of f? That is, what does 'x,/list-of-lists' do? does it flatten the list of lists and then concatenates x or does it flatten the list of lists x times? It seems confusing to have symbols that ac…
/ (like a lot of k symbols) does a few different things depending on context. In this case, if you do n f/x, where f takes a single argument (is a unary/monadic function), it applies f to x n times.
-2#x: yeah, it seems reasonable that it might negate the first two elements, APL uses ¯2 instead of -2 for this reason. In k however -2 is parsed as one number, as - then 2#...
Sure, there may be some complexities or questions, but there are in all languages, and in this case they were fairly simple things anyway to me.