[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-apl] Supporting negative ranks for ⍤ operator
From: |
Alexey Veretennikov |
Subject: |
Re: [Bug-apl] Supporting negative ranks for ⍤ operator |
Date: |
Mon, 02 May 2016 13:18:18 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.91 (darwin) |
Hi,
Here is the definition
http://help.dyalog.com/14.1/Content/Language/Primitive%20Operators/Rank.htm
Juergen Sauermann <address@hidden> writes:
> 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!
>
> Louis
>
> 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,
> Louis
>
> 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.
>
> Jay.
>
> 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
>
> So:
> 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
>
>
>
--
Br,
/Alexey