scan
inline fun <T, D : Dimension, R : Any> MultiArray<T, D>.scan(initial: R, operation: (acc: R, T) -> R): NDArray<R, D>
Content copied to clipboard
Returns a list containing successive accumulation values generated by applying operation from left to right to each element and current accumulator value that starts with initial value.
Note that acc
value passed to operation function should not be mutated; otherwise it would affect the previous value in resulting ndarray.
Parameters
operation
function that takes current accumulator value and an element, and calculates the next accumulator value.