A collection of utility functions for working with lists, maps, keyword lists, and strings.
This module is a convenience wrapper around the various Algo submodules, providing a single
namespace for importing functions.
Summary
Enumerable functions
Returns whether every element in an enumerable is unique.
Returns whether all elements are unique after applying a function.
Higher-order functions
Returns a comparator that checks equality after applying a function.
Enumerable functions
@spec all_different?(Enumerable.t()) :: boolean()
Returns whether every element in an enumerable is unique.
Examples
iex> Algo.all_different?([1, 2, 3])
true
iex> Algo.all_different?([1, 2, 1])
false
@spec all_different_by?(Enumerable.t(), (any() -> any())) :: boolean()
Returns whether all elements are unique after applying a function.
Examples
iex> Algo.all_different_by?(["a", "bb", "ccc"], &String.length/1)
true
iex> Algo.all_different_by?(["a", "b"], &String.length/1)
false
Higher-order functions
Returns a comparator that checks equality after applying a function.
Examples
iex> same_length? = Algo.eq_by?(&String.length/1)
iex> same_length?.("a", "b")
true
iex> same_length? = Algo.eq_by?(&String.length/1)
iex> same_length?.("a", "bb")
false
iex> Algo.unique_with(["a", "bb", "c"], Algo.eq_by?(&String.length/1))
["a", "bb"]
List functions
Map and keyword list functions
See Algo.Assoc.as_map/1.
See Algo.Assoc.evolve/2.
See Algo.Assoc.invert/1.
See Algo.Assoc.project/2.
See Algo.Assoc.prop/1.
See Algo.Assoc.props/1.