scan
Scan
f\y
x f\y
x f\y
scan, also known as cumulative reduce or scanl takes a dyadic function f
and reduces an array y
using it, while providing an array of intermediate values.
Scan works very similarly to fold.
+\1 2 3 4 5 1 3 6 10 15 ,\("ab";1;`d`a`b) ("ab" ("a";"b";1) ("a";"b";1;`d;`a;`b))
Specifying a left argument x
uses it as an initial value.
3 +\1 2 3 4 4 6 9 13
When used with functions that take more than 2 arguments, scan can take multiple arguments, of which the first one is always the initial value.
{x,y,z}\["A";1 2 3;"BCD"] (("A";1;"B") ("A";1;"B";2;"C") ("A";1;"B";2;"C";3;"D"))