The first advantage (write less code) is defeated by adding one more
function to the module, thereby increasing the API surface.

As for the second one, this code does one pass through the list:

Stream.map([1,2,3], & &1*2) |> Enum.sum

On Sat, Dec 1, 2018 at 6:19 PM Sean Handley <sean.hand...@gmail.com> wrote:

> Hello,
>
> I'd like to propose *Enum.sum/2*, where the second argument is a function.
>
> This will allow writing
>
> Enum.sum([1, 2, 3], &(&1 * 2))
>
> instead of
>
> Enum.map([1,2,3], &(&1 * 2)) |> Enum.sum()
>
> The advantages are:
>
> - Write less code.
> - One few iteration across the collection.
>
> I have a branch prepared -
> https://github.com/elixir-lang/elixir/compare/master...seanhandley:map_with_func
>
> Please let me know your thoughts.
>
> Cheers,
> Sean
>
> --
> 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/a6cb1e15-f32a-4e27-848d-ac8b80f080c0%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/a6cb1e15-f32a-4e27-848d-ac8b80f080c0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAAPY6eMtmpyK7DPGHQ4FLU%2BC8iHhn3SXAJ_i%3DvSWH-gFVYK2bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to