A Look At Folding

Currently I’m sitting the FP101x from edX. A portion of the homework was on foldr and foldl (i.e. right fold and left fold). This got me thinking how I might think about these ideas. Lets firstly compare the two. Prelude > foldr (-) 0 [1..4] -2 Prelude > foldl (-) 0 [1..4] -10 Why are they different? How do they work? foldl is probably the intuitive one. It simply “inserts” the function between the elements. [Read More]