Difference between reduce and foldLeft/fold in functional programming (particularly Scala and Scala APIs)?
问题 Why do Scala and frameworks like Spark and Scalding have both reduce and foldLeft ? So then what\'s the difference between reduce and fold ? 回答1: reduce vs foldLeft A big big difference, not mentioned in any other stackoverflow answer relating to this topic clearly, is that reduce should be given a commutative monoid , i.e. an operation that is both commutative and associative. This means the operation can be parallelized. This distinction is very important for Big Data / MPP / distributed