‹ BackHN Continuity

Thread

Anecdotally, programmers dislike "reduce"

175 points · 283 comments · vinhnx

  1. _moof · · focus · HN ↗
    What's hard to understand about it? It's just

      x = initial
      for y in collection:
        x = f(y, x)
    1. ema · · focus · HN ↗
      It's easy but it ain't simple. Because `f` can do arbitrary things to `x` you have to look at it just to know the general shape of the computation. Reduce gives you a lot of the flexibility of imperative programming but with that also a lot of the problems. Sometimes that's the right trade-off but it is good to be aware that it is a trade-off.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.