Skip to main content

Vector.running_fold

running_foldinitfunction

Documentation​

Combines all the elements of the vector, by iteratively applying the passed function with the next element of the vector. 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 vector​

     [1, 2, 3].running_fold 0 (+)