You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, the current version of fold can sum a list of numbers (but not an empty one!). But as soon as we want to do something more complicated where the accumulator is not of the same type as the elements, or we need to tolerate an empty list with some identity value, the current fold is unusable.
I propose the you add another argument or another version of the function that would allow people to provide their own starting accumulator. See fold vs fold1 in Haskell.
The text was updated successfully, but these errors were encountered:
Yes, the current version of fold can sum a list of numbers (but not an empty one!). But as soon as we want to do something more complicated where the accumulator is not of the same type as the elements, or we need to tolerate an empty list with some identity value, the current
fold
is unusable.I propose the you add another argument or another version of the function that would allow people to provide their own starting accumulator. See
fold
vsfold1
in Haskell.The text was updated successfully, but these errors were encountered: