Reduce, fold or scan (Left/Right)?
When should I use reduceLeft , reduceRight , foldLeft , foldRight , scanLeft or scanRight ? I want an intuition/overview of their differences - possibly with some simple examples. In general, all 6 fold functions apply a binary operator to each element of a collection. The result of each step is passed on to the next step (as input to one of the binary operator's two arguments). This way we can cumulate a result. reduceLeft and reduceRight cumulate a single result. foldLeft and foldRight cumulate a single result using a start value. scanLeft and scanRight cumulate a collection of intermediate