formulae v0.6.0 Formulae.Combinators

Helper to calculate all the combinations of the list given.

Examples

iex> Formulae.Combinators.combinations(~w|a b c d|a, 2)
[[:a, :b], [:a, :c], [:a, :d], [:b, :c], [:b, :d], [:c, :d]]
iex> Formulae.Combinators.permutations(~w|a b c d|a, 2)
[[:a, :b], [:a, :c], [:a, :d], [:b, :a], [:b, :c], [:b, :d],
 [:c, :a], [:c, :b], [:c, :d], [:d, :a], [:d, :b], [:d, :c]]
iex> Formulae.Combinators.repeated_permutations(~w|a b c d|a, 2)
[[:a, :a], [:a, :b], [:a, :c], [:a, :d], [:b, :a], [:b, :b],
 [:b, :c], [:b, :d], [:c, :a], [:c, :b], [:c, :c], [:c, :d],
 [:d, :a], [:d, :b], [:d, :c], [:d, :d]]

Link to this section Summary

Functions

Calculates all combinations of the list, given as the first parameter

Calculates all permutations of the list, given as the first parameter

Calculates all repeated permutations of the list, given as the first parameter

Link to this section Functions

Link to this function

combinations(list, n)

combinations(list :: list(), count :: non_neg_integer()) :: [list()]

Calculates all combinations of the list, given as the first parameter

Link to this function

permutations(list, n)

permutations(list :: list(), count :: non_neg_integer()) :: [list()]

Calculates all permutations of the list, given as the first parameter

Link to this function

repeated_permutations(list, arg2)

repeated_permutations(list :: list(), count :: non_neg_integer()) :: [list()]

Calculates all repeated permutations of the list, given as the first parameter