I would not be in favour of adding average to Enum for the simple reason
that there is no guarantee that average has meaning for a given enumerable.
Its Erlang's term ordering rules than mean max and min have meaning for all
terms. That is not true for averages.
On Monday, May 22, 2023 at
Whether any function is worth of stdlib is a really subtle topic, but I think
it'd be helpful to try to consider why average function hasn't been added yet.
>From my experience, the order on any kind of elements comes up pretty often,
>thus min/max values are widely used. In the same vein sum
Just as is there a function to get the *min,* *max, sum, *etc values from
an Enum, would be useful to have also an average function.
Enum.avg/1 or Enum.average/1
If it's ok for the community, I will be happy to implement it.
Example:
iex> Enum.avg(0..10)
5
--
You received this message