StreamFunctions2(A, B)ΒΆ

stream.spad line 1138

Functions defined on streams with entries in two sets.

map: (A -> B, Stream A) -> Stream B
map(f, s) returns a stream whose elements are the function f applied to the corresponding elements of s. Note: map(f, [x0, x1, x2, ...]) = [f(x0), f(x1), f(x2), ..].
reduce: (B, (A, B) -> B, Stream A) -> B
reduce(b, f, u), where u is a finite stream [x0, x1, ..., xn], returns the value r(n) computed as follows: r0 = f(x0, b), r1 = f(x1, r0), ..., r(n) = f(xn, r(n-1)).
scan: (B, (A, B) -> B, Stream A) -> Stream B
scan(b, h, [x0, x1, x2, ...]) returns [y0, y1, y2, ...], where y0 = h(x0, b), y1 = h(x1, y0), ... yn = h(xn, y(n-1)).