module Cf_seq:Lazily-evaluated sequences (functional streams).sig..end
cf library make
extensive use of this type.
The functions for manipulating static lists in the standard List library
all have equivalents here in this module. Additionally, there are some
convenient functions for converting structures with imperative interfaces
into sequences that permit functional algorithms to be applied.
type'at ='a cell Lazy.t
type 'a cell =
| |
P of |
(* | Element of a sequence | *) |
| |
Z |
(* | End of sequence | *) |
exception Empty
val nil : 'a tval head : 'a t -> 'aEmpty if the sequence
has no elements, i.e. if the sequence is Z.val tail : 'a t -> 'a tEmpty if the sequence has no elements, i.e.
if the sequence is Z.val concat : 'a t -> 'a t -> 'a tconcat a b returns the sequence of all the elements in a followed by
all the elements in b. Adds a constant cost to the evaluation of every
element in the resulting sequence prior to the start of elements from b,
so it may be worth considering the use of a Cf_deque object in place of
a Cf_seq object to avoid cost explosion.val flatten : 'a t t -> 'a tflatten a returns the sequence of all the elements in the sequence of
sequences by concatenating them.val limit : ?x:exn -> int -> 'a t -> 'a tlimit n s returns the sequence of all the elements in s, up to n
elements in number and no more. Raises Invalid_argument if n < 0.
If ?x is provided, then the exception is raised if the sequence is
evaluated past the limit.val shift : int -> 'a t -> 'a tshift n s returns the sequence of all the elements in s after the first
n elements are discarded. Returns the empty sequence if s has fewer
than n elements.val sentinel : exn -> 'a t -> 'a tsentinel x s returns a sequence identical to s except that x is raised
by evaluating to the end. This is intended for use in incremental sequence
processing.val reverse : 'a t -> 'a listreverse s evaluates the entire sequence and composes a list of the
elements in reverse order. Tail recursive.val length : 'a t -> intval unfold : ('a -> ('b * 'a) option) -> 'a -> 'b tunfold f a returns the sequence composed of the results of applying f
according to the following rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the owing rule: the first application of f is with a
as the argument; if the