The thing with `x_by` functions is that they still return the whole list (like 
in `sort_by`) or an element of it (like in `max_by`). 

Example right from `h Enum.max_by`:

```elixir
iex> Enum.max_by(["a", "aa", "aaa"], fn(x) -> String.length(x) end)
"aaa"
```

`Enum.sum` totally changes the returning value type to another, so I guess 
there is no point of having them since you can totally use the function `map` 
on your enumerable to get what you want. For example:

```elixir
iex> [“a”, “aa”, “aaa”] |> Stream.map(&String.length/1) |> Enum.sum()
=> 6
```

Best,
Kelvin Stinghen
kelvin.sting...@me.com

> On Feb 2, 2018, at 05:48, Alexey Chernenkov <a.y.chernen...@gmail.com> wrote:
> 
> I'm missing `Enum.sum_by/2` func. There are several other `xxx_by` methods 
> (e.g. `sort_by` and `max_by`).
> 
> -- 
> 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 
> <mailto:elixir-lang-core+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/elixir-lang-core/f7c51011-5ff4-4667-8125-75ced517887a%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/elixir-lang-core/f7c51011-5ff4-4667-8125-75ced517887a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <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/7D23AA55-92B7-4EAA-A062-09F6493C73C5%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to