-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I wonder if the sumFold example would be clearer if it were written using foldr instead of with foldl. In particular, because sumManual is written with the same kind of recursion as foldr, this would be easier to see:
Turns out, the definition of foldl contains all of that sweet recursive machinery needed to power our manual sum function:
foldr f z [] = z
foldr f z (x:xs) = x `f` foldr f z xs
sumManual [] = 0
sumManual (x:xs) = x + sumManual xsSee how well they line up?
(I really enjoy how this is written overall.)
Metadata
Metadata
Assignees
Labels
No labels