Inspired by @Tomerikoo's comment, I did a deeper research on reduce (aka fold). Many of the reduce/fold implementations in other languages require the operation to be associative. When the operation is associative, the order it is applied does not matter. For example, len("a") + len("b") + len("c") generates same results wherever you put the parenthesis (because integer addition on a finite field is associative).
The confusion happens when the operation is not associative. In this case the order the function is applied matters. This is when the concept of left fold and right fold comes in. They are both ways that stipulate how parenthesis is added.
Also note that fold requires two functions:
Function i that converts an object of type A to another of type B and
Functoin ii that reduces multiple type B objects into one single object of type C.
Left fold and right fold essentially use pairwise operations, which allows one to combine the two functions into one. This is the idea of @Andrej Kesely's answer.
int. From the second iteration onwards ofreduce, thexargument gets the previous return value (which is an int...). That's just howreduceworks