News for hackers. Stuff that matters.
Re:Writing Code to Be Spoken (2019) by kwhitefoot on Tuesday January 21, 2020 @04:28AM (#22105448)
Might have been more compelling if it had been illustrated using a more mainstream language.

For instance what does

    p⌿⍨
mean?
Re:Writing Code to Be Spoken (2019) by jodrellblank on Tuesday January 21, 2020 @06:56AM (#22106115)
It says, unhelpfully,

“P first-axis reduce or replicate/compress (commuted)”

Because APL functions only have a left and a right argument, and evaluates right to left but does parens first, it often means wrapping things on the left into parens to get them evaluated first. Commute (⍨) tacked onto a function reverses it’s arguments so you can put them the other way round and remove the parens e.g. 8-3 is 5 and 8-⍨3 is 3-8 is minus 5.

p⌿⍨... says (...)⌿p

Exactly what ⌿p does depends on what the rest is - it’s either a foldr operation if given a function, or “copy the items in p this many times each” if given a value or an array of values that matches the shape of p.

Looking at the link, it’s a replicate - that is, a filter. It filters p where the matching positions in t are =2, and t[p] is an array lookup (multiple indices at once) into another array.

I have no idea (yet?) how people say APL “reads left to right”, it seems to “decipher a bit at a time jumping all about from easy sections to hard sections”

Re:Writing Code to Be Spoken (2019) by 7thaccount on Tuesday January 21, 2020 @05:53AM (#22105813)
You gotta dig into APL a bit for these idioms to make sense.