For this challenge you are going to make a function (your function may be a complete program) that takes a list as input and returns a permutation of that list. Your function must obey the following requirements.
It must be deterministic.
Composing your function with itself a variable number of times should be capable of getting a list to any of its permutations.
This is a code-golf question so answers will be scored in bytes, with less bytes being better.
You may take any type of list, (
[[Integer]]) as long as it
- Can be non empty
- Can contain distinct objects with at least 16 possible values. (You can't use a Haskell
[()]and claim your function is
- Can contain duplicate objects (no sets)
You may write a program or a function, but must obey standard IO.