Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comprehensive list of synonyms for reduce

The higher order function typically known as reduce has a lot of synonyms in various languages.

Off the top of my head I can think of:

  • foldr, foldl (a.k.a right fold and left fold) (Haskell)
  • inject (Smalltalk, Ruby, Groovy)
  • Aggregate (LINQ)
  • accumulate (Wikipedia)
  • compress (Wikipedia)

Is there a comprehensive list of all the different names this function has? If not, let's make one here. It would be useful to know.

I'm not too interested in getting the library function names from each language, I'm looking for more of a colloquial, "how is it used in a sentence" type reference.

like image 548
Nick Knowlson Avatar asked Jun 04 '12 02:06

Nick Knowlson


2 Answers

You might note that in general, this concept is known as a catamorphism. From wikipedia, or also the cute article Functional programming with Bananas, Lenses, Envelopes and Barbed Wire.

like image 95
Kristopher Micinski Avatar answered Sep 23 '22 00:09

Kristopher Micinski


All right, so far the total list seems to be:

  • catamorphism (General term, see Kristopher's post)
  • reduce (Python, Clojure, Common Lisp, Ruby)
  • reduction (APL)
  • foldr, foldl (a.k.a right fold and left fold) (Haskell, Scheme)
  • inject (Smalltalk, Ruby, Groovy)
  • #inject:into (Smalltalk)
  • Aggregate (LINQ)
  • accumulate (Wikipedia)
  • compress (Wikipedia)
  • insertion (FP)
  • Insert (J)

Thanks for the help everyone, and if someone comes by later with a better list I'll make sure to accept that one instead!

like image 29
Nick Knowlson Avatar answered Sep 23 '22 00:09

Nick Knowlson