Packages

A helper library with functions of Mathematics Combinations

Current section

Files

Jump to
math_combinations lib array_permutation.ex
Raw

lib/array_permutation.ex

defmodule ArrayPermutation do
def of([h|t]), do: permute([h|t])
defp permute([]), do: [[]]
defp permute(list), do: for elem <- list, rest <- permute(list--[elem]), do: [elem|rest]
end