Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-module joe.
-export [test/0, perms/1].
test() ->
[[]] = joe:perms(""),
["a"] = joe:perms("a"),
["ab", "ba"] = joe:perms("ab"),
["ba", "ab"] = joe:perms("ba"),
["123","132","213","231","312","321"] = joe:perms("123"),
ok.
perms([]) -> [[]];
perms([H|T]) -> [ [H|P] || P <- perms(T) ].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.