[Top][All Lists]

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

Re: [Bug-apl] EACH by axis

From: Elias Mårtenson
Subject: Re: [Bug-apl] EACH by axis
Date: Mon, 31 Mar 2014 15:34:38 +0800

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.


On 31 March 2014 15:29, Jay Foad <address@hidden> wrote:
On 31 March 2014 04:51, Elias Mårtenson <address@hidden> 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')

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

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


reply via email to

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