12.6 DataStream Modification

Export of DataStream

map: (T -> T) -> % -> %

Usage

T == Integer;
init(n: MachineInteger, x: DataStream): T == {zero? n => 0; x(n-1) + 1}
s: DataStream T := stream init;
f(t: T): T == 2*t;
t: DataStream T := map(f)(s);

Description

Maps a function on a stream.

Remarks

If the input stream s is eventually constant, the output stream t is eventually constant, too. In other, words, f is supposed to return the same result on the same input.

422aexports: DataStream 392a+   (386)  419
map: (T -> T) -> % -> %;
422bimplementation: DataStream 392b+   (386)  420
map(f: T -> T)(x: %): % == stream(f t for t in elements x);