3 ms·
Might have been more compelling if it had been illustrated using a more mainstream language. For instance what does p⌿⍨ mean?
by kwhitefoot 7y ago
Might have been more compelling if it had been illustrated using a more mainstream language.
For instance what does
p⌿⍨
mean?
- 7thaccount 7y agoYou gotta dig into APL a bit for these idioms to make sense.
- jodrellblank 7y agoIt 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”