Hi,

improvements on the rank operator are already on my TO list (see README-4-compliance). I guess ⍤[] probably allows rank along any axis, but I have not yet investigated that.

/// Jürgen


On 03/31/2014 09:34 AM, Elias Mårtenson wrote:
Jay, thanks for reminding me of the rank operator. I had forgotten about that one. :-)

Yes, in this case it would definitely do the right thing, but as you mention it won't allow you to work on other axes.

Regards,
Elias


On 31 March 2014 15:29, Jay Foad <[email protected] <mailto:[email protected]>> wrote:

    On 31 March 2014 04:51, Elias Mårtenson <[email protected]
    <mailto:[email protected]>> wrote:
    > I keep wanting to be able to apply an axis argument to the ¨ (EACH)
    > operator. I.e, to sort an array rows, I wanted to do:
    >
    > {⍵[⍋⍵]}¨[2] foo
    >
    >
    > Instead, I had to do:
    >
    > ⊃ {⍵[⍋⍵]}¨ ⊂[2] foo
    >
    >
    > Would it make sense to be able to specify an axis number to the
    the EACH
    > operator as an extension?

    Hi Elias,

    Have you considered using the Rank operator?

          {⍵[⍋⍵]}⍤1(4 3⍴'FEEFIEFOEFUM')
    EEF
    EFI
    EFO
    FMU

    There is a bit of tension in APL between these two different ways of
    solving the same kinds of problem: primitives-with-axis, and the Rank
    operator.

    - Primitives-with-axis are a bit ad hoc. Every primitive interprets
    the axis specification in a different way, and some primitives (like
    Each) don't support it at all.

    - By contrast, the Rank operator is completely uniform and applies to
    all functions.

    - But the Rank operator restricts you to dividing the argument up
    along the leading axes. (Some would argue that this restriction is a
    good thing.) E.g. you can use it to sort each row of a matrix, but not
    to sort each column.

    Jay.



Reply via email to