Previous Up Next

5.10.2  Previous permutation: prevperm

The prevperm takes as argument a permutation.
prevperm returns the previous permutation in lexicographic order, or undef if there is no previous permutation.
Input:

prevperm([0,3,1,2])

Output:

[0,2,3,1]

Previous Up Next