Stream.transform is already optimized for cases where you emit one or zero element, so it is definitely the way to go. And we don't have any _reduce function in Stream exactly because you can't get the accumulator.
*José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D On Fri, Jul 14, 2017 at 9:52 AM, Michał Muskała <[email protected]> wrote: > I was looking recently into transforming a stream in a one-to-one way that > requires maintaining an additional accumulator during the transition. > That's an obvious use case for map_reduce with Enum, but with Stream we > lack such a function. We have transform/3 that is somewhat equivalent to > Enum.flat_map_reduce, that we could use here, but I think I'd prefer > something simpler. I'm not 100% sure about the name, though. > > Michał. > > -- > 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/2e5eb853-9fd8-4410-a82c-18da0297d4b5%40Spark > <https://groups.google.com/d/msgid/elixir-lang-core/2e5eb853-9fd8-4410-a82c-18da0297d4b5%40Spark?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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JWK9JRNarJuo4ZPpB05-n%2B6s5U3k0SHt5rxWbEzbLGKQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
