9

Are the functions accumulate, compress, fold & reduce synonyms?

Tim McNamara
  • 17,513
  • 4
  • 50
  • 80
  • 2
    as function names are just that, and not all this names exists in every functional-language you should be a bit more specific on context of which functional language you use. – kriss Sep 10 '10 at 05:21
  • Is a sort of a cross-link acceptable here: http://stackoverflow.com/questions/3082324/foldl-versus-foldr-behavior-with-infinite-lists Haskell is quite refined in its handling of these constructions. – JohnRood Oct 01 '12 at 06:13
  • `accumulate` and `reduce` are difference things in Python. The first one returns the list of all intermidiate accumulated values. – Vadim Pushtaev Feb 03 '19 at 10:06
  • in C++, replacing std::accumulate with std::reduce can allow parallelization and vectorization, but leads to horrible bugs if your operation is not commutative and associative (axioms which the compiler can't check). – TamaMcGlinn Nov 03 '20 at 15:53

1 Answers1

9

Well, it depends on the language. It is a common function with different names in different languages.
See: Wikipedia entry

But yes, it's commonly known as the names you mentioned plus inject.
The Wikipedia entry has a more comprehensive list of its aliases in several languages.

Jeremy
  • 1
  • 83
  • 335
  • 359
NullUserException
  • 81,190
  • 27
  • 202
  • 228
  • and also some of these names are used for slighlty different (or even completely different) meanings. Like compress to call some compression algorithm. – kriss Sep 11 '10 at 13:17