Note that each (¨) is an operator -- there is no ambiguity.
⍴¨(1 2 3)(1 2)(1 2 3 4 5)
3 2 5
which (I suspect), you would rathereach(rho, ((1 2 3) (1 2) (1 2 3 4 5)))
So -- your example would be (better)
transpose(take(each(index, x), x))
Quoting the GNU APL manual:
"There are 4 APL symbols / ⌿ \ and ⍀ that can be functions or operators, depending on their context (i.e. depending on the APL tokens left of them). Neither the ISO standard nor the otherwise excellent IBM APL2 language reference manual explain the rules that decide whether, for example /, should mean ’function compress’ or ’operator reduce’. In simple cases the meaning of / is obvious: +/B means ’operator reduce’ while 1/B means ’function compress’. "
" an become more complex if index brackets or parentheses are involved. The algorithm used in GNU APL for classifying / and friend is (simplified) this:
1. / ⌿ \ and ⍀ are tokenized as operators
2. Scan the tokenized statement from left to right to find / ⌿ \ or ⍀
3. If a / ⌿ \ or ⍀ is found, go backwards until a constant, or a function, or a user-defined name is found: 3a. if a constant, a function, or a user-defined name is found then →4 3b. if ) is seen then skip over it, That is, a parenthesized expression is entered. 3c. if ] is seen then skip until the corresponding [ is found, That is an index list or axis is skipped over. 3d. otherwise: SYNTAX ERROR
4. decide the role of / \ ⌿ or ⍀ based on the kind of token that was found in 3a: 4a. function: leave / as operator as initially tokenized 4b. constant: change / from operator to function (compress) 4c. see below
This works fine except in case 4c. which cannot be resolved at ⎕FX time. For this case we introduce the following convention:
A user-defined name is assumed to be a function (and hence / is an operator) unless the name (and nothing else) is enclosed in parentheses. For example:
A / B ⍝ A is function, therefore / is operator
(A) / B ⍝ A is value, therefore / is function
This rule is moderately compatible with ISO and APL2; in APL2 (A) would be redundant parentheses so in that case there would be a small incompatibility between GNU APL and IBM APL2.
" transpose(take(each(index, x), x))
Thank you! That's indeed easier for me to read. A bit tricky to understand what it does, but that's just a matter of reading the reference for each function in turn.