Learn R Programming

polyMatrix (version 0.3.1)

permNext: The next permutation

Description

Returns for a permutation the next permutation

Usage

permNext(prm)

Arguments

prm

the length of required permutation, or the permutation for which the next we will

Value

The next permutation in lexicographic oder.

Details

When it is a natural number, then the program take it as the length of the required permutation, and returns the first permutation of the given length. If it is a sequence of natural numbers then it read it as a permutation, and returns the lexicographic next permutation of the same sequence.

See Also

permSign,ssetNext

Examples

Run this code
# NOT RUN {
# expect 1 2 3 4
permNext(4)
permNext(c(1,2,3,4))
permNext(c(4,2,3,1))
# }

Run the code above in your browser using DataLab