Skip to content

Instantly share code, notes, and snippets.

@sleepiecappy
Created May 18, 2019 18:35
Show Gist options
  • Save sleepiecappy/bd978b97a61e36343bde923f900bc087 to your computer and use it in GitHub Desktop.
Save sleepiecappy/bd978b97a61e36343bde923f900bc087 to your computer and use it in GitHub Desktop.
Generate Permutations on List
defmodule Permutation do
def permutations([]), do: [[]]
def permutations(list),
do: for(elem <- list, rest <- permutations(list -- [elem]), do: [elem | rest])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment