This works in Dyalog APL but not in GNU APL:
{10<⊃⍵:⍵ ⋄ ∇ ⍵,⍨+/2↑⍵}1
The error I get is
Illegal : in immediate execution+
I am using the REPL but I tried running it from a file as well but it didn't work either.
If something I am using is specific to Dyalog, what is the correct GNU way to do it?
GNU APL does not support guards (than is, {condition:if_condition_true ⋄ else}
) in direct functions.
Try use a del (∇
) definition and convert the program to use loop (actually, go to) so that it is APL2 compatible:
∇r←f x
r←x
LOOP:→(10<⊃r)/0
r←r,⍨+/2↑r
→LOOP
∇
f 1
13 8 5 3 2 1 1
If you want to learn APL using GNU APL, you'll have to look for tutorials and books for APL2 that does not use too much Dyalog APL extended features, for example APL--An Interactive Approach, Second Edition (which is excellent for teaching you use del editor).