This is a followup post to: Functional Swift: Fold it, baby!
The Accumulator Value
A small tip I forgot to mention about the initial accumulator value. Often times you can think of it as the neutral element of the operation you pass to fold. For example in the sum function the operation is addition. To not affect the final solution by the initial accumulator you use the neutral element to addition, which is zero.
More Variants of Fold
Speaking of the initial accumulator value, there is a version of fold that uses the first element of the list as its initial accumulator called foldl1. And these two versions of fold can be reversed so that the list is processed from right to left, foldr and foldr1.
Like foldl but with the first element as the starting accumulator.
func foldl1<A>(list: Array<A>, f: (A