11

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

Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Tim McNamara
  • 18,019
  • 4
  • 52
  • 83
  • 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
  • 1
    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
  • 1
    `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

10

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
  • 85
  • 340
  • 366
NullUserException
  • 83,810
  • 28
  • 209
  • 234
  • 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