[Top][All Lists]

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

Re: [Bug-apl] Supporting negative ranks for ⍤ operator

From: Juergen Sauermann
Subject: Re: [Bug-apl] Supporting negative ranks for ⍤ operator
Date: Mon, 02 May 2016 12:41:13 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

Hi Louis,

just for curiosity, where are negative ranks defined?
My version of "Mastering Dyalog APL" (ISBN : 978-0-9564638-0-7) does
not even mention the rank operator.

/// Jürgen

On 04/28/2016 12:31 AM, Louis de Forcrand wrote:
Whoops. Looks like I got here too late.
Well done!


On 28 Apr 2016, at 00:29, Louis de Forcrand <address@hidden> wrote:

The three-item form is used if the associated function is ambivalent (applied to the P-cells of ⍵ if monadic, applied to corresponding Q-cells of ⍺ and R-cells of ⍵ if dyadic). I don't believe it is possible to define ambivalent functions in ISO APL however, so it is kind of redundant. It is probably left over from Sharp APL.

As to the negative rank, I believe that it is an obvious flaw in the standard. Being able to apply a function to the items of the argument is incredibly useful. Of course this is achievable like so:
{⍺ (f ⍤ (¯1+≢⍴⍺⍵)) ⍵} ⍝ without ⍺ for the monadic form
Now that I've checked, I'm pretty sure that GNU APL does support rank (negative or not), but not with all primitives. Try it out with ⊖ or +⌿ on a rank-3 or above array, and then with ]BOXING and ⊂ on the same array… looks like a bug to me.

The rank operator isn't easy to grasp, and it's surely harder to implement.

Good luck,

On 27 Apr 2016, at 13:14, Jay Foad <address@hidden> wrote:

Incidentally, it works like this in Dyalog and NARS2000 too, though
the Dyalog documentation doesn't mention the 3-item form.


On 27 April 2016 at 09:02, Jay Foad <address@hidden> wrote:
Given g ← f⍤P Q R:
P is the monadic rank
Q is the left rank
R is the right rank

g Y applies g to the P-cells of Y
X g Y applies g to the Q-cells of X and the R-cells of Y

The ⌽3⍴⌽y1 stuff is just a too-cute way of saying that you can specify
fewer than 3 values in the right operand, and:
R is shorthand for R R R
Q R is shorthand for R Q R

reply via email to

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