Darwin Help

Back to Index

Permutation

Class Permutation - a mathematical permutation

Calling Sequence  Permutation(p)
Permutation(n)
Parameters
NameTypeDescription

p list(posint)list of integers from 1 to n
n posintcreates an identity permutation of size n
Return Type  Permutation
Methods power, Rand, string, times, type
Synopsis A Permutation holds a list of consecutive positive integers which describe how to permute a set of size n. Permutations can be multiplied (the product of two permutations a * b is a permutation which is identical to applying b and then a). Permutations can also be powered, in particular an inverse permutation is obtained by 1/a.
Examples
> a := Rand(Permutation(7));
a := Permutation([5, 4, 6, 3, 1, 7, 2])
> b := Rand(Permutation(7));
b := Permutation([1, 6, 3, 2, 7, 5, 4])
> a*b;
Permutation([7, 2, 5, 3, 1, 4, 6])
> 1/a;
Permutation([5, 7, 4, 2, 1, 3, 6])
See also CreateRandPermutation,   Mutate,   Rand,   Shuffle