Executing Scalar Operations
All APL executable units are called functions, even if they’re known as operators in other languages (for example, + and *). Many functions have a unary (monadic, only with the right argument) and a binary (dyadic, with both arguments) form. Function calls can also be nullary (niladic, no arguments). All functions are right-associative—executed from right to left, and this is another catch. What do you think is the result of 10-5-3-1? No, it’s not 1.
| | 10-5-3-1 ⍝ 10-(5-(3-1)) |
| | 7 |
If you don’t like the default evaluation order, use parentheses.
| | ((10-5)-3)-1 |
| | 1 |
The right associativity rule may cause unpleasant surprises that are hard to detect and defuse (here and later, the symbol ⇨ is not a part of APL ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access