I think zip_with is still valuable as is because a zip_with without an accumulator can be streamable (i.e. in the Stream module) but a zip_with with an accumulator cannot. We may be looking at a zip_reduce in the future though, given use cases are provided. :)
On Tue, Feb 2, 2021 at 11:29 PM [email protected] <[email protected]> wrote: > How embarrasing I typo'd the subject. It should read Should zip / > zip_with have a reducer? > > Best > > Adam > > On Tuesday, February 2, 2021 at 10:27:49 PM UTC [email protected] wrote: > >> Hello! >> >> I was thinking about zip_with/3 et al. (don't judge me I'm in a >> lockdown). >> >> Currently they work by returning a list, but would it not make more sense >> for it to take an accumulator? >> >> ```elixir >> Enum.zip_with([1, 2], [3, 4], %{}, fn left, right, acc -> Map.put(acc, >> left, right) end) >> %{ 1 => 3, 2 => 4 } >> >> Enum.zip_with([1, 2], [3, 4], [], fn left, right, acc -> [{left, right} | >> acc] end) >> [{1, 3}, {2, 4}] >> ``` >> If so... I guess it also opens to door for a zip_while. >> >> Am I mad? Has science gone too far? >> >> Best >> >> Adz >> >> >> -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/468649a3-7e6f-4214-99d8-6e8ef5e6d72an%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/468649a3-7e6f-4214-99d8-6e8ef5e6d72an%40googlegroups.com?utm_medium=email&utm_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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4L3uLCP9xMwVvdw%2BQPpGP-GtjzE7ZdXL0M7ZKmzjDGRXA%40mail.gmail.com.
