Enum.min/3
defmodule Enum do
def min(
enumerable,
sorter \\ &<=/2,
empty_fallback \\ fn -> raise(Enum.EmptyError) end
)
end
Returns the minimal element in the enumerable according to Erlang’s term ordering.
By default, the comparison is done with the <=
sorter function. If multiple elements are considered minimal, the first one that was found is returned.
If the enumerable is empty, the provided empty_fallback
is called.
The default empty_fallback
raises Enum.EmptyError
.