Range.running_fold
running_foldinitfunction
Documentation
Combines all the elements of the range, by iteratively applying the passed function with the next element of the range. After each step the value is stored resulting in a new Vector of the same size as self.
Arguments
init
: The initial value for the fold.function
: A function taking two elements and combining them.
Examples
Compute the running sum of all of the elements in a range.
(0.up_to 4).running_fold 0 (+)