[Top][All Lists]

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

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

From: Kacper Gutowski
Subject: Re: [Bug-apl] Strange behaviour of ,/
Date: Fri, 31 Jan 2014 20:52:28 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

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
      (3 4⍴⊂0 0) ≡,⌿2 3 4⍴0 ⍝Enclose-Reduction-Style

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).


reply via email to

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