‹ BackHN Continuity

Thread

Anecdotally, programmers dislike "reduce"

175 points · 283 comments · vinhnx

  1. ducaale · · focus · HN ↗
    I find `reduce` useful for operations where:

    - arg1, arg2 and return value are all of the same type e.g `ADD`, `MAX`, `CONCAT` etc

    - and there is an identity value e.g zero for `ADD`, -math.inf for `MAX`

    I recommend checking this article[1] on how monoids play nicely with reduce.

    [1] <a href="https:&#x2F;&#x2F;fsharpforfunandprofit.com&#x2F;posts&#x2F;monoids-without-tears&#x2F;#what-use-are-monoids-to-a-programmer" rel="nofollow">https:&#x2F;&#x2F;fsharpforfunandprofit.com&#x2F;posts&#x2F;monoids-without-tear...

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.