w=: 'STOP' 3 2 0 1 { w POST 2 3 1 0 { w OPTS 3 0 2 1 { w PSOTThe left arguments of { above are themselves permutations of the list i.4 ; examples of permutation vectors, used to represent permutation functions in the form p&{ .
]c=: C. p=: 2 4 0 1 3 +---+-----+ |2 0|4 3 1| +---+-----+ c C. 'ABCDE' C. c CEABD 2 4 0 1 3Each of the boxed elements of a cycle specify a list of positions that cycle among themselves; in the example above, the element from position 3 moves to position 4 , element 1 moves to 3 , and element 4 to 1 .
1 A. 'ABCDE' A. 0 1 2 4 3 ABCED 1 (i.!3) A. i.3 (i.!3) A. 'ABC' 0 1 2 ABC 0 2 1 ACB 1 0 2 BAC 1 2 0 BCA 2 0 1 CAB 2 1 0 CBA
Exercises
25.1 | Use the following as exercises in reading and writing (try
on a=:'abcdef' and b=: i. 6 and c=: i. 6 6): f=: 1&A. Interchange last two items g=: 3&A. Rotate last three items h=: 5&A. Reverse last three items i=: <:@!@[ A. ] k i a reverses last k items |
25.2 | Experiment with the following expressions and others
like them to determine the rules for using abbreviated arguments
to C. and compare your conclusions with the
dictionary definitions: 2 1 4 C. b=:i.6 (<2 1 4) C. b (3 1;5 0) C. b |
25.3 | Make a program ac that produces a table of the cycle
representations of all permutations of the order of its argument,
as in ac 3 . Answer: ac=: C.@(i.@! A. i.) |