Re: [elixir-core:11410] [Proposal] Add function average or avg to Enum module.

2023-05-22 Thread Kip
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 10:25:36 AM UTC-10 Andrey Yugai wrote:

> 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 also tends 
> to pop up whenever some sort of data processing happens. 
>
> Now, there are domains that involve number crunching, and within them it's 
> imperative to have average, mode, median and whatnot to achieve any result. 
> But it's important to have in mind these are more specialized applications 
> of a language. They're far better served in external libraries, allowing 
> users to make a choice of not including this functionality in app, and also 
> enabling the most efficient implementation possible, like Nx having its own 
> compilation pipeline to bypass limitations of BEAM. 
>
>
>
>
>
>  Original Message 
> On 23 May 2023, 03:05, Julian Somoza < julian...@gmail.com> wrote:
>
>
> 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 because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elixir-lang-co...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elixir-lang-core/CACFi_YPY5QURbQ8G%3DqA%3Dt6iQLWUToQygU-jo1%2BzdmW%3DFE3EmKw%40mail.gmail.com
>  
> 
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/fc56f73c-9839-476a-8c6c-65a809a122a1n%40googlegroups.com.


Re: [elixir-core:11408] [Proposal] Add function average or avg to Enum module.

2023-05-22 Thread 'Andrey Yugai' via elixir-lang-core
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 also tends to pop up 
>whenever some sort of data processing happens.

Now, there are domains that involve number crunching, and within them it's 
imperative to have average, mode, median and whatnot to achieve any result. But 
it's important to have in mind these are more specialized applications of a 
language. They're far better served in external libraries, allowing users to 
make a choice of not including this functionality in app, and also enabling the 
most efficient implementation possible, like Nx having its own compilation 
pipeline to bypass limitations of BEAM.

 Original Message 
On 23 May 2023, 03:05, Julian Somoza wrote:

> 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 because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/elixir-lang-core/CACFi_YPY5QURbQ8G%3DqA%3Dt6iQLWUToQygU-jo1%2BzdmW%3DFE3EmKw%40mail.gmail.com](https://groups.google.com/d/msgid/elixir-lang-core/CACFi_YPY5QURbQ8G%3DqA%3Dt6iQLWUToQygU-jo1%2BzdmW%3DFE3EmKw%40mail.gmail.com?utm_medium=email_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/J_IB_hb5CNOER5NIoYcv-28EEkg3U0v7A3YWAu71h5s3HwQhIHxw6v6hwoM3-6vztv7wfenrMcAhFKR90X3Tv0nAuKyjWxPT5KWsi_St9hs%3D%40pm.me.


[elixir-core:11407] [Proposal] Add function average or avg to Enum module.

2023-05-22 Thread Julian Somoza
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 because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CACFi_YPY5QURbQ8G%3DqA%3Dt6iQLWUToQygU-jo1%2BzdmW%3DFE3EmKw%40mail.gmail.com.