4 ms·
Also, right folds preserve the structure of the datatype folded over. If you fold right over a list with the empty list as the start value and cons (or (_::_) i
by fhars 15y ago
Also, right folds preserve the structure of the datatype folded over. If you fold right over a list with the empty list as the start value and cons (or (_::_) in scala) as the operation, you get the original list back (i.e. same value, not same object). A left fold on the other hand is just some arbitrary looping constuct.