|
From: | Juergen Sauermann |
Subject: | Re: [Bug-apl] Defining APL functions with [ ] |
Date: | Tue, 03 Jun 2014 12:15:53 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
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:
|
[Prev in Thread] | Current Thread | [Next in Thread] |