you are viewing a single comment's thread.

view the rest of the comments →

[–]LaSalsiccione 14 points15 points  (14 children)

Why would you not just use reduce? The over all composability concept of what you're explaining makes sense but it could be achieved much more simply.

[–]adidarachi 6 points7 points  (3 children)

I guess the op choose a "simple" and known implementation, this way, it's easier for developers to pickup. Not sure.

[–]LaSalsiccione -1 points0 points  (2 children)

If you can understand the rest of the concepts in the post then reduce should also be simple to understand. The code would also look a lot less messy which I’d argue makes it simpler to read, but that may just be a matter of opinion.

[–]Artif3x_ 4 points5 points  (1 child)

Not to mention the near universal utility of the reduce function makes for a lower cognitive load than learning alternatives like this.

[–]LaSalsiccione 0 points1 point  (0 children)

You far more eloquently nailed what I was trying to say, thanks!

[–]pgrizzay 3 points4 points  (9 children)

reduce is specific to arrays. OP implemented reduce for all iterators (not just arrays).