greg (12/09/82)
I read about a fascinating characteristic of grade-down in a back issue of APL News (right now I can't find my pile of back issues, so I can't give a reference). Consider a random arrangement of the positive integers 1 through N. For concreteness let us take N to be 4, and our arrangement to be 3 1 2 4. Form an N by N matrix with zeroes in every slot of each column except for the position indicated by the corresponding slot of our vector. In other words, for each i from 1 to N, m[ vec[ i ]; i ] is 1, and all the other locations of m are zero. For our sample, we have: vec: 3 1 2 4 m: 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 The (zero-origin) function named 'mat' takes a vector m and produces the desired matrix: z { mat n z { (2 rho rho n) take (1, rho n) rho 1 z { (-n-1) reverse[ 0 ] z Now for the punch line: 'mat grade-down vec' produces a matrix which is the same as 'mat vec', but rotated 90 degrees clock-wise! grade-down vec: 4 1 3 2 m': 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 (The proof is left to the reader.) :-) A corollary of the above is that 'gd gd gd gd' is the identity function for permutation vectors. - Greg Johnson U Wis - Madison