r/sml • u/ben_cow • Oct 17 '20
How to create a list containing all the permutations of a list using only recursion?
Trying to figure out how to get a function that takes a list and returns a list of lists such that the function returns a list of all the permutations of the input list using only recursion and I can't use map or currying.
Example: perms([0,1,2])= [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]].
Any help would be appreciated.