combinat
nextperm
construct the lexicographic successor of a given permutation
prevperm
construct the lexicographic predecessor of a given permutation
firstperm
construct the first permutation in lexicographic order
lastperm
construct the last permutation in lexicographic order
Calling Sequence
Parameters
Description
Thread Safety
Examples
Compatibility
nextperm( p )
prevperm( p )
firstperm( n )
lastperm( n )
p
-
permlist; permutation of positive integers from 1 to n for some n
n
nonnegint; degree of the permutation
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 ].
The combinat[nextperm], combinat[prevperm], combinat[firstperm] and combinat[lastperm] commands are thread-safe as of Maple 16.
For more information on thread safety, see index/threadsafe.
with⁡combinat
Chi,bell,binomial,cartprod,character,choose,composition,conjpart,decodepart,encodepart,eulerian1,eulerian2,fibonacci,firstcomb,firstpart,firstperm,graycode,inttovec,lastcomb,lastpart,lastperm,multinomial,nextcomb,nextpart,nextperm,numbcomb,numbcomp,numbpart,numbperm,partition,permute,powerset,prevcomb,prevpart,prevperm,randcomb,randpart,randperm,rankcomb,rankperm,setpartition,stirling1,stirling2,subsets,unrankcomb,unrankperm,vectoint
nextperm⁡1,3,2
2,1,3
nextperm⁡4,3,2,1
FAIL
prevperm⁡2,1,3
1,3,2
prevperm⁡1,2,3,4,5
firstperm⁡4
1,2,3,4
lastperm⁡3
3,2,1
The combinat[nextperm], combinat[prevperm], combinat[firstperm] and combinat[lastperm] commands were introduced in Maple 16.
For more information on Maple 16 changes, see Updates in Maple 16.
See Also
combinat[permute]
Download Help Document