Page
Library
Module
Module type
Parameter
Class
Class type
Source
Zlist
SourceLazily-realized lists.
val pp :
sep:(Format.formatter -> unit -> unit) ->
(Format.formatter -> 'a -> unit) ->
Format.formatter ->
'a t ->
unit
Pretty-print a lazy list with items separated by sep
. This will traverse the entire list, so printing an infinite or very long list is inadvisable.
of_array xs
is a lazy list consisting of the items in the array xs
.
These functions are used to generate lazy lists from specifications.
fill n a
generates a lazy list consisting of n
instances of the item a
.
State-based generation.
Starting with an initial state, generate a new state and a value. Termination is indicated by an outcome of None
.
Generate an infinite lazy list by repeatedly iterating on a value.
continually a
generates an infinite lazy list consisting of the item a
.
enum_from z
generates an infinite lazy list consisting of the integers beginning at z
and incremented by one at each step.
Like enum_from
, but the result is a finite lazy list that terminates at the upper bound.
take_while f t
is a lazy list consisting of the first items of t
that satisfy the predicate f
. The first item in t
that does not satisfy the predicate terminates the sequence.
drop_while f t
is the lazy list t
without the first items that satisfy the predicate f
. The first item in t
that does not satisfy the predicate terminates the sequence.
map f t
is the lazy list t
with the f
applied to each of its items.
filter f t
is the lazy list t
with only the items that satisfy the predicate f
.
map_filter f t
applies f
to each element in t
and produces a new lazy list consisting of the non-None
values.
Check for the existence of an item in the lazy list that satisfies a predicate.
The first item to satisfy the predicate terminates the realization of the list.
Check that all items in the lazy list satisfy the predicate.
This requires realizing the entirety of the structure.
Return the first item in the lazy list that satisfies the predicate.
Combine two lazy lists into a single lazy list, one after the other.
Merge two lazy lists together with a generating function.
Like zip_with
, but merge elements from differently sized lazy lists.
Like zip
, but merge elements from differently sized lazy lists.
Fold over a lazy list from the right with an accumulation function.
Since the folding function is lazy in the second argument, evaluation of the lazy list can be short-circuited.
Fold over a lazy list from the left with an accumulation function.
Compare two lazy lists for equality with an element comparison function.