firstperm - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


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

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.

• 

For more information on thread safety, see index/threadsafe.

Examples

withcombinat

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

(1)

nextperm1,3,2

2,1,3

(2)

nextperm4,3,2,1

FAIL

(3)

prevperm2,1,3

1,3,2

(4)

prevperm1,2,3,4,5

FAIL

(5)

firstperm4

1,2,3,4

(6)

lastperm3

3,2,1

(7)

Compatibility

• 

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

combinat[permute]