FWIW, I've always appreciated that reduce passes them in the order it does to the function, because it's the same order that they are passed into reduce, which has made it easy for me to remember the order they come in.
Enum.reduce(items, acc, fn item, acc -> ... end) Allen Madsen http://www.allenmadsen.com On Wed, Dec 9, 2020 at 10:24 AM Bruce Tate <[email protected]> wrote: > Good points. > > The form Enum.reduce([4, 3, ...], 10, &subtract(&2, &1)) is pretty > reasonable. > > -bt > > On Wed, Dec 9, 2020 at 10:08 AM José Valim <[email protected]> wrote: > >> >> Thanks Bruce for the proposal. >> >> I have run into this and, generally speaking, I have addressed it by >> using &1, ...: >> >> Enum.reduce([4, 3, ...], 10, &subtract(&2, &1)) >> >> Still quite concise. Most often the function I call in reduce also needs >> other parameters and that handles it well: >> >> Enum.reduce([4, 3, ...], 10, &something(&2, param, &1)) >> >> My concern with adding fold is that it will spiral out of control: fold, >> map_fold, flat_map_fold, fold_while, etc. >> >> -- >> 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/CAGnRm4KUbSv0diJvjcOCM55jfUiP%2Bi4-rshT6zCyQk_cWAu8LA%40mail.gmail.com >> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KUbSv0diJvjcOCM55jfUiP%2Bi4-rshT6zCyQk_cWAu8LA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > > > -- > > Regards, > Bruce Tate > CEO > > > <https://bowtie.mailbutler.io/tracking/hit/f8218219-d2a8-4de4-9fef-1cdde6e723f6/c7c97460-016e-45fb-a4ab-0a70318c7b97> > > Groxio, LLC. > 512.799.9366 > [email protected] > grox.io > > -- > 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/CAFXvW-4-ZTehsziMEf3GnaD6Ue3vFr1cqv4neOaTzmZ-%3Dirt9A%40mail.gmail.com > <https://groups.google.com/d/msgid/elixir-lang-core/CAFXvW-4-ZTehsziMEf3GnaD6Ue3vFr1cqv4neOaTzmZ-%3Dirt9A%40mail.gmail.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/CAK-y3Cvgzuec4bELQG4D--h6rMbOdJfkwcjLcTbcePAK9rz-FQ%40mail.gmail.com.
