5 ms·
In case anyone else is curious, but having trouble parsing that, "1≥⍵:⍵" means "return the input ⍵, for ⍵≤1", "⋄" is a statement separator, and "(∇⍵-1)+∇⍵-2" ef
by AlexCoventry 7y ago
In case anyone else is curious, but having trouble parsing that, "1≥⍵:⍵" means "return the input ⍵, for ⍵≤1", "⋄" is a statement separator, and "(∇⍵-1)+∇⍵-2" effectively means "otherwise, return fib(⍵-1)+fib(⍵-2)". ("∇⍵-2" means "∇(⍵-2)", because, as mentioned in the video, APL expressions are evaluated right-to-left.)
The {} indicate that this is a function definition: https://www.gnu.org/software/apl/apl.html#Section-3_002e7 https://www.gnu.org/software/apl/apl.html#Section-3_002e7
My initial take on this, at least, is that it seems pretty reader-hostile. Maybe you get used to it, though.
- dTal 7y agoThat is truly beautiful. I already loved APL, from a distance as it were, but this gives me renewed respect for it.
- segmondy 7y agoIt's as reader hostile as mathematics symbol is reader hostile. It's not English, it's not meant to be read like a novel but to be read and understood like mathematics. One of the frustrating thing about programming in English like languages is that words might not mean what they claim to mean. Written language is very ambiguous. Nothing from stoping me from writing something as not_true = true; if (not_true) { ... }. or calling something manager or a process when it's neither. Easy to read and pronounce but harder to digest. The idea of APL is that once you understand the symbol like maths, it's unambiguous, if you can parse it, you can understand. There's no crazy naming to confuse you.
- AlexCoventry 7y agoProgramming is generally not mathematics, though. Usually, you're doing something considerably more complex, though also more concrete.