1

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?

1
  • 1
    From the docs it looks like GNU APL dfns are crippled beyond usability: "There are a number of features related to lambdas that are present in other APL interpreters but that are NOT implemented in GNU APL. This includes multiple statements, guards, lexical scoping, and probably more." gnu.org/software/apl/apl.html#Limitations-of-Lambdas
    – B. Wilson
    Commented Jul 12 at 22:24

1 Answer 1

2

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.