Vector.reduce
reducefunctionif_empty
Documentation
Combines all the elements of a non-empty vector using a binary operation. If the vector is empty, it returns if_empty
.
Arguments
function
: A binary operation that takes two items and combines them.if_empty
: Value returned if the vector is empty.
Examples
Compute the sum of all the elements in a vector.
[0, 1, 2] . reduce (+)