Enum.min_max
You're seeing just the function
min_max
, go back to Enum module for more information.
Link to this function
min_max(enumerable, empty_fallback \\ fn -> raise(Enum.EmptyError) end)
View SourceSpecs
min_max(t(), (() -> empty_result)) :: {element(), element()} | empty_result when empty_result: any()
Returns a tuple with the minimal and the maximal elements in the enumerable according to Erlang's term ordering.
If multiple elements are considered maximal or minimal, the first one that was found is returned.
Calls the provided empty_fallback
function and returns its value if
enumerable
is empty. The default empty_fallback
raises Enum.EmptyError
.
Examples
iex> Enum.min_max([2, 3, 1])
{1, 3}
iex> Enum.min_max([], fn -> {nil, nil} end)
{nil, nil}