package containers
Install
Dune Dependency
Authors
Maintainers
Sources
md5=03b80e963186e91ddac62ef645bf7fb2
sha512=c8f434808be540c16926bf03d89f394d33fc2d092f963a7b6d412481229e0a96290f1ad7c7d522415115d35426b7aa0b3fda4b991ddc321dad279d402c9a0c0b
doc/containers.iter/CCKList/index.html
Module CCKList
Source
Continuation List
Basics
repeat ~n x
repeats x
n
times then stops. If n
is omitted, then x
is repeated forever.
Cycle through the iterator infinitely. The iterator shouldn't be empty.
unfold f acc
calls f acc
and:
- if
f acc = Some (x, acc')
, yieldx
, continue withunfold f acc'
. - if
f acc = None
, stops.
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.
a -- b
is the range of integers containing a
and b
(therefore, never empty).
Operations on two Collections
Fold on two collections at once. Stop at soon as one of them ends.
Map on two collections at once. Stop as soon as one of the arguments is exhausted.
Iterate on two collections at once. Stop as soon as one of them ends.
Combine elements pairwise. Stop as soon as one of the lists stops.
Misc
Eager sort. Require the iterator to be finite. O(n ln(n))
time and space.
Eager sort that removes duplicate values. Require the iterator to be finite. O(n ln(n))
time and space.
Fair Combinations
Implementations
Infix version of fair_flat_map
.
Infix operators
Conversions
Convert to a list, in reverse order. More efficient than to_list
.