Scan (f\)¶
Syntax¶
f is a dyadic scalar function. Y is the argument array.
Description¶
Like reduce, but keeps all intermediate results. Element i of the result is f/ applied to the first i+1 elements. The result has the same shape as the input.
Scan is left-to-right: for +\ a b c d, the result is a, a+b, (a+b)+c, ((a+b)+c)+d.
Examples¶
Higher-rank arrays¶
On matrices, scan works along the last axis. The result has the same shape as the input.
Empty arrays¶
Scanning an empty array returns an empty array.
See also¶
- Reduce (
f/) -- full reduction - First-axis variants -- use
(f\⍤¯1)for first-axis scan