Skip to content

Instantly share code, notes, and snippets.

@holsee
Created March 17, 2015 14:00
Show Gist options
  • Save holsee/c8c1b071cb5d5a2c6eeb to your computer and use it in GitHub Desktop.
Save holsee/c8c1b071cb5d5a2c6eeb to your computer and use it in GitHub Desktop.
Find All Permutations of List
defmodule Sjt do
def perms([]), do: [[]]
def perms(l = [_h|_t]) do
for h <- l, t <- perms(l -- [h]), do: [h|t]
end
end
@holsee
Copy link
Author

holsee commented Mar 17, 2015

Not sure this is really a SJT implementation, but finds all perms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment