DarkMatter.Lists (DarkMatter v1.1.4) View Source

Utils for working with lists or improper lists

Link to this section Summary

Functions

Flattens common tree shaped keyword lists into a single list

Split list into uniques

Split list into uniques by fun

Link to this section Types

Link to this type

atom_or_improper_tree_list()

View Source

Specs

atom_or_improper_tree_list() ::
  atom()
  | maybe_improper_list()
  | {atom(),
     atom()
     | maybe_improper_list()
     | {atom(), atom() | maybe_improper_list() | {any(), any()}}}

Link to this section Functions

Link to this function

flatten_atom_or_improper_tree_list(val)

View Source

Specs

flatten_atom_or_improper_tree_list(atom_or_improper_tree_list()) :: [atom()]

Flattens common tree shaped keyword lists into a single list

Examples

iex> flatten_atom_or_improper_tree_list([])
[]

iex> flatten_atom_or_improper_tree_list(:atom)
[:atom]

iex> flatten_atom_or_improper_tree_list([:atom_list])
[:atom_list]

iex> flatten_atom_or_improper_tree_list({:tuple, :atom})
[:tuple, :atom]

iex> flatten_atom_or_improper_tree_list([tuple: :list])
[:tuple, :list]

iex> flatten_atom_or_improper_tree_list([tuple: [nested: :atom]])
[:tuple, :nested, :atom]

iex> flatten_atom_or_improper_tree_list([tuple: [nested: [:list, :atom]]])
[:tuple, :nested, :list, :atom]

iex> flatten_atom_or_improper_tree_list([:atom, tuple: [nested: [:nested2, nested3: [:nested4]]]])
[:atom, :tuple, :nested, :nested2, :nested3, :nested4]

Specs

split_uniq(Enumerable.t()) :: {Enumerable.t(), Enumerable.t()}

Split list into uniques

Link to this function

split_uniq_by(enumerable, fun)

View Source

Specs

split_uniq_by(Enumerable.t(), (any() -> any())) ::
  {Enumerable.t(), Enumerable.t()}

Split list into uniques by fun