Reduction and the rank operator

General APL language issues

Reduction and the rank operator

Postby marc on Wed Sep 16, 2015 1:12 pm

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)?
marc
 
Posts: 8
Joined: Wed Nov 09, 2011 8:36 pm

Re: Reduction and the rank operator

Postby Phil Last on Wed Sep 16, 2015 4:10 pm

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.
User avatar
Phil Last
 
Posts: 628
Joined: Thu Jun 18, 2009 6:29 pm
Location: Wessex

Re: Reduction and the rank operator

Postby marc on Wed Sep 16, 2015 4:47 pm

Thanks Phil, that makes sense.
marc
 
Posts: 8
Joined: Wed Nov 09, 2011 8:36 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest