From what I understand about folds in Haskell, foldl (-) 0 [1..5]
gives a result of -15
by calculating 0-1-2-3-4-5
, and foldr (-) 0 [1..5]
gives a result of -5
by calculating 5-4-3-2-1-0
. Why is it then that both foldl (++) "" ["a", "b", "c"]
and foldr (++) "" ["a", "b", "c"]
give a result of "abc"
, and the result of foldr
is not, instead, "cba"
?
Is there something I'm missing in understanding the differences between foldl
and foldr
?