Reduction and the rank operator

General APL language issues
Post Reply
marc
Posts: 8
Joined: Wed Nov 09, 2011 8:36 pm

Reduction and the rank operator

Post by marc »

Would anyone be able to clarify the interaction between the rank and reduction operators? For example, given the following session:

      +⌿[1]a←2 3 4⍴⍳24
12 15 18 21
48 51 54 57
+/[1]a
12 15 18 21
48 51 54 57
(+⌿⍤2)a
12 15 18 21
48 51 54 57
(+/⍤2)a
6 22 38
54 70 86


it's unclear to me why reduce and reduce first behave differently. Shouldn't the rank operator determine the domain of reduction (analgous to the way in which the axis operator collapses the distinction in the first two expressions)?
User avatar
Phil Last
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Reduction and the rank operator

Post by Phil Last »

Note origin zero and the origin independent nature of the words "first", "second" and "last".

You probably know that the first two are the same because the axis spec overrides the difference between / and ⌿ and reduces (removes) the second ([1]) dimension.

The next is the same because you are removing the first dimension of each three-by-four two-cell which again is the second ([1]) dimension.

The last is different because you are removing the last dimension of the two-cells which is the last ([2]) dimension.

Roger will correct me if I'm wrong but I believe that there is never any purpose to using / and ⍤ together.
marc
Posts: 8
Joined: Wed Nov 09, 2011 8:36 pm

Re: Reduction and the rank operator

Post by marc »

Thanks Phil, that makes sense.
Post Reply