3 ms·
It's nice to note when you think about for loops, while, etc. versus map/each/reduce that the latter offer a convenience that is not discussed enough: the abili
by VeejayRampay 11y ago
It's nice to note when you think about for loops, while, etc. versus map/each/reduce that the latter offer a convenience that is not discussed enough: the ability to reason about a single element of a collection without having ever to think about the collection itself (no thinking about bounds, indices or things like that).
This in turn, makes it easier to think in terms of :
I have a thing, I put it in the box and a new different thing comes out of that box.
That in turn can more easily lead to thinking about series of connected boxes.
- Sharlin 11y agoAnd after that, you can start thinking about other kinds of boxes: Maybe/Optional, Either/Try, futures, infinite collections, lazy collections, I/O streams, message passing systems... all of which can be manipulated with the same set of primitives. And at some point you realize there's a name for this fancy abstraction and it starts with an "m" and ends with a "d" and Haskellers like it very much.