Package lepl :: Package stream :: Module iter
[hide private]
[frames] | no frames]

Module iter

source code

A stream for iterable sources. Each value in the iteration is considered as a line (which makes sense for files, for example, which iterate over lines).

The source is wrapped in a Cons object. This has an attribute head which contains the current line and a method tail() which returns another Cons instance, or raise a StopIteration.

The stream has the form (state, helper), where helper is an IterableHelper instance, as described below.

The state value in the stream described above has the form (cons, line_stream) where cons is a Cons instance and line_stream is a stream generated from cons.head (so has the structure (state', helper') where state' and helper' depend on the type of the line and the stream factory used).

Evaluation of stream methods then typically has the form: - call to IterableHelper - unpacking of state - delegation to line_stream - possible exception handling

This has the advantages of being generic in the type returned by the iterator, of being customizable (by specifying a new factory), and re-using existing code where possible (in the use of the sub-helper). It should even be possible to have iterables of iterables...

Classes [hide private]
A linked list cell that is a lazy wrapper around an iterable.
Implement a stream over iterable values.
Functions [hide private]
base_iterable_factory(state_to_line_stream, type_)
IterableHelper and the token helper differ mainly in how they map from state to line_stream.
source code