Previous page Table of Contents Next page
A stream is a stateful object that effectively combines a sequence and an iteration state for that sequence. Unlike iterating through a sequence, iterating through a stream changes the stream.
The following method requirements constitute the stream protocol:
defprotocol stream end?(x is stream, result: end? is boolean) next(x is stream, result: element) advance(x is stream)Their behavior is very similar to the methods of the same names of the sequence protocol. There is no start-iteration method, as this happens automatically when a stream is created. The advance method does not return anything in particular.
There is a pseudo-constructor method stream that takes a sequence and returns a stream that iterates through that sequence.
Previous page Table of Contents Next page