Next permutation
Cycles through permutations of first argument
nextp(perm, b = 1)
perm
b
The next permutation
Useful links