Proposal: Enum.zip/3

78 views
Skip to first unread message

ad...@a-corp.co.uk

unread,
Oct 7, 2020, 9:36:43 AM10/7/20
to elixir-lang-core
Hello,

Would the community be open to a 3 arity Enum.zip function which takes a function as the last argument?

```elixir
Enum.zip([1,2], [2,3], fn x, y -> x + y end) #=> [3, 5]
```

I presume we could make this more efficient than `Enum.zip |> Enum.map` because we could iterate through the collection once instead of twice.

Best

Adam

José Valim

unread,
Oct 7, 2020, 9:40:57 AM10/7/20
to elixir-l...@googlegroups.com
Yes, please. I believe it is conventionally called Enum.zip_with/3, so perhaps we should go with the same name?

--
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/e546a439-5571-49d9-b07e-4876f57ad678n%40googlegroups.com.

Andrea Leopardi

unread,
Oct 7, 2020, 9:45:03 AM10/7/20
to elixir-lang-core

Adam Lancaster

unread,
Oct 7, 2020, 9:48:08 AM10/7/20
to elixir-l...@googlegroups.com
Nice, I’ll get a PR together when I get a chance.

Cheers

Adam

ad...@a-corp.co.uk

unread,
Oct 11, 2020, 6:19:39 PM10/11/20
to elixir-lang-core
Just to follow up I've raised a PR here: https://github.com/elixir-lang/elixir/pull/10419

Comments welcome!

Adam
Reply all
Reply to author
Forward
0 new messages