Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"reduce" (or fold) certainly takes a while getting used to, but once you gain some intuition for it, it is pretty reusable and it avoids all the problems mentioned above such as off-by one errors etc.

also, if you use map + reduce, it's totally trivial to parallelise the map part and have the main thread combine the partial updates since there is no shared mutable state, e.g. Java also offers parallel streams that support this with basically zero effort. if you use loops, it can be quite hard to rewrite the code so that it is thread safe.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: