The fold point is that it is more abstract. This does not mean that you can do what you could not do before, so that you can make them easier.
Using fold , you can generalize any function that is defined for two elements applicable to an arbitrary number of elements. This is a win, because it is usually easier to write, test, maintain and modify a single function that uses two arguments rather than a list. And it's always easier to write, test, maintain, etc. One simple function instead of two with a similar, but not quite functional.
Since fold (and, for that matter, map , filter and friends) have well-defined behavior, it is often much easier to understand code using these functions than explicit recursion.
Basically, if you have one version, you get the other "for free." Ultimately, you end up doing less work to get the same result.
Ezra
source share