StreamFunctions2(A, B)ΒΆ
stream.spad line 1194 [edit on github]
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 functionf
applied to the corresponding elements ofs
. Note:map(f, [x0, x1, x2, ...]) = [f(x0), f(x1), f(x2), ..]
.
- reduce: (B, (A, B) -> B, Stream A) -> B
reduce(b, f, u)
, whereu
is a finite stream[x0, x1, ..., xn]
, returns the valuer(n)
computed as follows:r0 = f(x0, b), r1 = f(x1, r0), ..., r(n) = f(xn, r(n-1))
.