Minmaxlist
Adds min_list_by/2
, max_list_by/2
and min_max_list_by/2
that’s not in Enum
.
Summary
Functions
Returns list of entries that gives the maximum value as calculated by the given function. Returns empty list if the collection is empty
Returns list of entries that gives the minimum value as calculated by the given function. Returns empty list if the collection is empty
Returns a tuple with two lists of entries that give minimum & maximum values respectively as calculated by the given function. Returns a tuple of two empty lists if the collection is empty
Types
element :: any
t :: Enumerable.t
Functions
Returns list of entries that gives the maximum value as calculated by the given function. Returns empty list if the collection is empty.
iex> [1, 2, 3, 4, 5, 6] |> Minmaxlist.max_list_by(&(rem(&1,3)))
[2, 5]
iex> [] |> Minmaxlist.max_list_by(&(rem(&1,3)))
[]
Returns list of entries that gives the minimum value as calculated by the given function. Returns empty list if the collection is empty.
iex> [1, 2, 3, 4, 5, 6] |> Minmaxlist.min_list_by(&(rem(&1,3)))
[3, 6]
iex> [] |> Minmaxlist.min_list_by(&(rem(&1,3)))
[]
Returns a tuple with two lists of entries that give minimum & maximum values respectively as calculated by the given function. Returns a tuple of two empty lists if the collection is empty.
iex> [1, 2, 3, 4, 5, 6] |> Minmaxlist.min_max_list_by(&(rem(&1,3)))
{[3, 6], [2, 5]}
iex> [] |> Minmaxlist.min_max_list_by(&(rem(&1,3)))
{[], []}