4 ms·
Right. It's just one more thing you have to think about with Reduce that's not something you have to consider with Map/Filter.
by snackbroken 18d ago
Right. It's just one more thing you have to think about with Reduce that's not something you have to consider with Map/Filter.
- Lvl999Noob 18d agoIf you have need of a reducing operation though, you will still need to think about that value. If you are summing up a list of numbers, it doesn't matter whether you use reduce or a loop, you need to set some initial value.
- mcphage 18d agoI agree, although most of the time you do end up needing to consider it with Map/Filter. It's just, it doesn't force you to. Which means either you think about it later, or it bites you in the ass because you didn't consider the empty case. Not always—and for those cases where you don't end up needing the empty case, Reduce is probably not necessary, and Map/Filter is sufficient.