PERMUTE procedure

Forms all possible permutations of the integers 1...n (J.W. McNicol & R.W. Payne).


Option

SORT = string
Whether or not to sort the permutations (no, yes); default no


Parameters

NVALUES = scalars
Specifies the final number, n, in the sequence of integers 1...n to be permuted

PERMUTATIONS = pointers
Pointer to a set of variates of length NVALUES storing the permutations


Description

PERMUTE forms all the permutations of the integers 1 up to the value n specified by the NVALUES parameter. The permutations are saved, as a set of variates each of length NVALUES, in a pointer supplied by the PERMUTATIONS parameter. By default, the permutations will occur in an arbitrary order, but option SORT can be set to yes to sort them into the standard (lexicographic) order.


Option: SORT.

Parameters: NVALUES, PERMUTATIONS.


Method

The procedure uses the standard GenStat manipulation directives, CALCULATE, EQUATE etc.