The code is organized through the class EmptyStream (empty list
or tail), the class ConsStream (list value and lazy pointer to next),
and the type alias Stream (empty or cons).
Finally, "static" functions on Option are arranged in the class
StreamStatic and are accessed through the global constant Stream.
Use take() for instance to reduce an infinite stream to a finite one.
Examples:
Stream.iterate(1, x => x*2).take(4);
=> Stream.of(1,2,4,8)
Stream.continually(Math.random).take(2);
=> Stream.of(0.49884723907769635, 0.3226548779864311)
A lazy, potentially infinite, sequence of values.
The code is organized through the class EmptyStream (empty list or tail), the class ConsStream (list value and lazy pointer to next), and the type alias Stream (empty or cons).
Finally, "static" functions on Option are arranged in the class StreamStatic and are accessed through the global constant Stream.
Use take() for instance to reduce an infinite stream to a finite one.
Examples:
Stream.iterate(1, x => x*2).take(4); => Stream.of(1,2,4,8) Stream.continually(Math.random).take(2); => Stream.of(0.49884723907769635, 0.3226548779864311)