92

JS map, filter, reduce...

Comments
  • 9
    Wow this is actually really good!
  • 1
    so reduce in js is aggregate in linq?
  • 1
    Great explanation 🤣😂
  • 2
    @bigworld12 reduce, aggregate and fold are all the same, they are catamorphisms. Generators/unfolds are anamorphic:

    f = n => n > 0 ? [n, ...f(n - 1)] : []

    Map is the homomorphism. An unfold-fold is an hylomorphism. Then there are para/apomorphisms which are like cata/ana but retaining their shape (I think filter is paramorphic, reduce + keep?)

    My beard is not long enough yet to store all the category theory stuff.
  • 3
    @bittersweet whatlanguageisthismorphism
  • 3
    @hack Math.

    The constructs programmers use to fold/unfold/map/etc are called morphisms in set theory, transformations in linear algebra and functors in category theory.

    To make it confusing, in functional programming (Clojure/Haskell/etc) the category of mappables/reducables is often referred to as functors while functors are labelled morphisms.
  • 0
    😁😁
  • 0
    Short but really nice explaination
Add Comment