|
Calling Sequence
|
|
nextperm( p )
prevperm( p )
firstperm( n )
lastperm( n )
|
|
Parameters
|
|
p
|
-
|
permlist; permutation of positive integers from 1 to n for some n
|
n
|
-
|
nonnegint; degree of the permutation
|
|
|
|
|
Description
|
|
•
|
Given a permutation p (of type permlist) of the integers 1 through n, for some n, the command nextperm returns the lexicographic successor of p.
|
•
|
If p is the lexicographically last permutation of degree n (that is, [n,n-1,...,2,1]), then the value FAIL is returned.
|
•
|
Given a permutation p (of type permlist) of the integers 1 through n, for some n, the command prevperm returns the lexicographic predecessor of p.
|
•
|
If p is the first permutation of degree n in lexicographic order (that is, [1,2,...,n-1,n]), then the value FAIL is returned.
|
•
|
The command firstperm returns the first permutation, in lexicographic order, of the permutations of the set {1,2,...,n} of integers from 1 to n. This is the permutation [ 1, 2, ..., n ].
|
•
|
The command lastperm returns the last permutation, in lexicographic order, of the permutations of the set {1,2,...,n} of integers from 1 to n. The lexicographically last permutation of {1,2,...,n} is [n, n-1, ..., 2, 1 ].
|
|
|
Thread Safety
|
|
•
|
The combinat[nextperm], combinat[prevperm], combinat[firstperm] and combinat[lastperm] commands are thread-safe as of Maple 16.
|
|
|
Examples
|
|
| (1) |
>
|
|
>
|
|
>
|
|
>
|
|
| (6) |
|
|
Compatibility
|
|
•
|
The combinat[nextperm], combinat[prevperm], combinat[firstperm] and combinat[lastperm] commands were introduced in Maple 16.
|
|
|
|