|
From: | Elias Mårtenson |
Subject: | Re: [Bug-apl] Strange behaviour of ,/ |
Date: | Sat, 1 Feb 2014 04:09:49 +0800 |
On 2014-02-01 01:37:23, Elias Mårtenson wrote:That's how reduction is informally described, but join isn't a simple
> As far as I understand, OP/ is supposed to splice OP in between every element
> in the array and return the result.
>
> Based on this, I would expect that ,/1 2 3 4 and 1,2,3,4 to be equivalent.
scalar function so precise definition matters in this case.
Your example gives the same results in other systems as well.
> Am I misunderstanding or is GNU APL doing something wrong?
If I read the ISO standard correctly, there are two slightly different
conforming definitions for reduce and GNU APL uses what they call
enclose-reduction-style. It essentially boils down to this:
f/1 2 3 4 ←→ ⊂1 f ⊃f/2 3 4
In fact, standard explicitly gives these two examples:
(3 8⍴0) ≡,⌿2 3 4⍴0 ⍝Insert-Reduction-Style
1
(3 4⍴⊂0 0) ≡,⌿2 3 4⍴0 ⍝Enclose-Reduction-Style
1
Note that enclose is a no-op for simple scalars so +/1 2 3 4
isn't nested at all (it matches the informal description).
-k
[Prev in Thread] | Current Thread | [Next in Thread] |