val nil : 'a t
val empty : 'a t
val singleton : 'a ‑> 'a t
val repeat : ?n:int ‑> 'a ‑> 'a t
repeat ~n x
repeats x
n
times then stops. If n
is omitted,
then x
is repeated forever.
val unfold : ('b ‑> ('a * 'b) option) ‑> 'b ‑> 'a t
unfold f acc
calls f acc
and:
f acc = Some (x, acc')
, yield x
, continue with unfold f acc'
.f acc = None
, stops.val is_empty : 'a t ‑> bool
Unsafe version of tail.
val iter : ('a ‑> unit) ‑> 'a t ‑> unit
val length : _ t ‑> int
Number of elements in the list. Will not terminate if the list if infinite: use (for instance) take to make the list finite if necessary.
Fair product of two (possibly infinite) lists into a new list. Lazy. The first parameter is used to combine each pair of elements.
Specialization of product_with producing tuples.
group eq l
groups together consecutive elements that satisfy eq
. Lazy.
For instance group (=) [1;1;1;2;2;3;3;1]
yields
[1;1;1]; [2;2]; [3;3]; [1]
.
uniq eq l
returns l
but removes consecutive duplicates. Lazy.
In other words, if several values that are equal follow one another,
only the first of them is kept.
val range : int ‑> int ‑> int t
val (--) : int ‑> int ‑> int t
a -- b
is the range of integers containing
a
and b
(therefore, never empty).
val (--^) : int ‑> int ‑> int t
a -- b
is the integer range from a
to b
, where b
is excluded.
Eager sort that removes duplicate values. Require the iterator to be
finite. O(n ln(n))
time and space.
val return : 'a ‑> 'a t
val pure : 'a ‑> 'a t
module Infix : sig ... end
val of_list : 'a list ‑> 'a t