Implementation of the Johnson Trotter algorithm.
JohnsonTrotter.first [ "a", "b", "c" ]
|> JohnsonTrotter.getState
|> Maybe.map JohnsonTrotter.next
|> Maybe.andThen JohnsonTrotter.getPermutation
-- [ "a", "c", "b" ]Initialises permutations. The first argument specifies the list that you want to get permutations for.
Get the next permutation. The first argument is the current State of the algorithm, which is in the Step returned by first and next. Use the getState helper funtion to retrieve the State from Step.
Get the permutation from Step, if there is one.
Represents the next permutation, if there is one.