You first example uses conventional APL "del" notation to define a function. The second two examples use direct definition (commonly known as dfns - pronounced dee-funs) which is an extension by Dyalog APL, and obviously does not run in the interpreter you are using. The ease of defining functions this way is a great advantage.
Question
I am using GNU APL 1.1 (svn 4460)
on Linux 2.6.32
and I have some problems with function definitions.
This snippet works as expected:
∇R←ODD N
R←2|N
∇
(ODD L)/L←⍳10
But when I try this
{2|⍵} 5
or this
ODD←{2|⍵}
I get a syntax error. The same snippets run fine here.
I am a complete beginner to APL. Could anyone explain me what causes this syntax error?
Solution
OTHER TIPS
The dfns (function fragment in curly braces) syntax is not supported by all APLs. If it's not supported, expect a syntax error or nonce error.
To my knowledge, only Dyalog APL and NGN APL (see http://ngn.github.io/apl/web/) support it.
Sharp APL had a direct definition feature but the syntax was rather different.
NGN APL does not support legacy function definition, only dfns.
GNU APL has now a support for such dfns; you can try it by compiling it from the subversion repository or wait for the release 1.3.