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. 3 Answers 3
When should I use reduceLeft, reduceRight, foldLeft, foldRight, scanLeft or scanRight? I want an intuition/overview of their differences – possibly with some simple examples. 3 Answers 3
I have learned the basic difference between foldLeft and reduceLeft foldLeft: initial value has to be passed reduceLeft: takes first element of the collection as initial value throws exception if collection is empty Is there any other difference ? Any specific reason to have two methods with similar functionality? 8 Answers 8