Hi,
yes, the reason is this:
Sometimes you want to have (user-defined) wrapper functions around
primitives, for example
to get some statistics about their use (how often called, averge size of
arguments, etc).
It is pretty easy to convert a normal APL program to one using the
wrappers instead of
the primitives.
That fails, however, when a primitive function or operator has an axis
argument.
I also found it generally more plausible if user defined function can
also have an
axis argument. For example you can define the average of a vector like this:
∇Z←Avg B
Z←(+/B) ÷ (⍴B)
∇
But you can't normally define the average along an axis like this:
∇Z←Avg[X] B
Z←(+/[X]B) ÷ (⍴B)[X]
∇
With GNU APL you can:
Avg[1] 5 5⍴⍳25
11 12 13 14 15
Avg[2] 5 5⍴⍳25
3 8 13 18 23
/// Jürgen
On 06/03/2014 04:39 AM, Elias Mårtenson wrote:
As far as I understand, it's an extension that is unique to GNU APL.
Regards,
Elias
On 3 June 2014 10:37, Blake McBride <[email protected]
<mailto:[email protected]>> wrote:
Greetings,
APL-1 did not allow functions to be defined with [ and ] in the
header. I've seen it done in GNU APL as follows:
∇fun[⎕]∇
∇
[0] fun[x]y
[1] x
[2] y
∇
fun[4]55
4
55
I understand what is going on, but I was looking for it in the
APL-2 manuals. I couldn't find it in any of the IBM manuals (and
the spec is unreadable to me). So, my question is, where in the
IBM APL-2 Language Manual is it shown? Any place else?
Thanks.
Blake