Range.reduce
reducefunctionif_empty
Documentation
Combines all the elements of a non-empty range using a binary operation. If the range is empty, returns if_empty
.
Arguments
function
: A binary operation that takes two integers and combines them.if_empty
: Value returned if the range is empty.
Examples
Compute the sum of all the elements in a range.
0.up_to 10 . reduce (+)