bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Strange behaviour of ,/


From: Elias Mårtenson
Subject: Re: [Bug-apl] Strange behaviour of ,/
Date: Sat, 1 Feb 2014 04:09:49 +0800

Wow. I need to read (and understand) the spec, clearly. Thanks for explaining this to me.

Regards,
Elias


On 1 February 2014 03:52, Kacper Gutowski <address@hidden> wrote:
On 2014-02-01 01:37:23, Elias Mårtenson wrote:
> 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.

That's how reduction is informally described, but join isn't a simple
scalar function so precise definition matters in this case.

> Am I misunderstanding or is GNU APL doing something wrong?

Your example gives the same results in other systems as well.
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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]