Created
May 18, 2019 18:35
-
-
Save sleepiecappy/bd978b97a61e36343bde923f900bc087 to your computer and use it in GitHub Desktop.
Generate Permutations on List
This file contains hidden or 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 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