-
-
Save holsee/c8c1b071cb5d5a2c6eeb to your computer and use it in GitHub Desktop.
Find All Permutations of List
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sjt do | |
def perms([]), do: [[]] | |
def perms(l = [_h|_t]) do | |
for h <- l, t <- perms(l -- [h]), do: [h|t] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure this is really a SJT implementation, but finds all perms