From 0e578235051f1e597a9a5665634b41bfe2ea6c46 Mon Sep 17 00:00:00 2001 From: c-cube Date: Fri, 12 Feb 2021 19:41:59 +0000 Subject: [PATCH] deploy: b5ecb273ef0cf16351bb8295b79863c562f1218c --- dev/containers/CCList/index.html | 2 +- dev/containers/CCListLabels/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/containers/CCList/index.html b/dev/containers/CCList/index.html index 18a722b4..9f01ca2c 100644 --- a/dev/containers/CCList/index.html +++ b/dev/containers/CCList/index.html @@ -1,5 +1,5 @@ -CCList (containers.CCList)

Module CCList

Complements to list

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a

Documentation for the standard List module

include module type of Stdlib.List
type !'a t = 'a list =
| ([])
| (::) of 'a * 'a list
val length : 'a list -> int
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> int -> int
val cons : 'a -> 'a list -> 'a list
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : int -> (int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val iteri : (int -> 'a -> unit) -> 'a list -> unit
val map : ('a -> 'b) -> 'a list -> 'b list
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> 'a list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val find_opt : ('a -> bool) -> 'a list -> 'a option
val find_map : ('a -> 'b option) -> 'a list -> 'b option
val filter : ('a -> bool) -> 'a list -> 'a list
val find_all : ('a -> bool) -> 'a list -> 'a list
val filteri : (int -> 'a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> ('a * 'b) list -> bool
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val to_seq : 'a list -> 'a Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

since
0.11
val map : ('a -> 'b) -> 'a t -> 'b t

map f [a0; a1; …; an] applies function f in turn to a0; a1; …; an. Safe version of List.map.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

l >|= f is the infix version of map with reversed arguments.

since
0.5
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

val filter : ('a -> bool) -> 'a t -> 'a t

filter p l returns all the elements of the list l that satisfy the predicate p. The order of the elements in the input list l is preserved. Safe version of List.filter.

val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold_right f [a1; …; an] b is f a1 (f a2 ( … (f an b) … )). Safe version of List.fold_right.

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

fold_while f init l folds until a stop condition via ('a, `Stop) is indicated by the accumulator.

since
0.8
val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map f init l is a fold_left-like function, but it also maps the list to another list.

since
0.14
val fold_map_i : ('acc -> int -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map_i f init l is a foldi-like function, but it also maps the list to another list.

since
2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> 'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce init l combines map f and fold_left reduce init in one operation.

since
2.8
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list

scan_left f init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val reduce : ('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

since
3.2
val reduce_exn : ('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

raises Invalid_argument

if the given list is empty.

since
3.2
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 f init l1 l2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : ('acc -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map f init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_filter_map_i : ('acc -> int -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i f init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

since
2.8
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val fold_flat_map_i : ('acc -> int -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
2.8
val count : ('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

since
1.5, but only
since
2.2 with labels
val count_true_false : ('a -> bool) -> 'a list -> int * int

count_true_false p l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate p, and int2 the number of elements that do not satisfy p.

since
2.4
val init : int -> (int -> 'a) -> 'a t

init len f is f 0; f 1; …; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

since
3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

val flat_map_i : (int -> 'a -> 'b t) -> 'a t -> 'b t

flat_map_i f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

since
2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

val product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

product comb l1 l2 computes the cartesian product of the two lists, with the given combinator comb.

val fold_product : ('c -> 'a -> 'b -> 'c) -> 'c -> 'a t -> 'b t -> 'c

fold_product f init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1]; [l2]; …; [ln]] produces the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
+CCList (containers.CCList)

Module CCList

Complements to list

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a

Documentation for the standard List module

include module type of Stdlib.List
type !'a t = 'a list =
| ([])
| (::) of 'a * 'a list
val length : 'a list -> int
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> int -> int
val cons : 'a -> 'a list -> 'a list
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : int -> (int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : ('a -> unit) -> 'a list -> unit
val iteri : (int -> 'a -> unit) -> 'a list -> unit
val map : ('a -> 'b) -> 'a list -> 'b list
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b list
val filter_map : ('a -> 'b option) -> 'a list -> 'b list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b list -> 'a * 'c list
val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b list -> 'a
val fold_right : ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b
val iter2 : ('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
val fold_right2 : ('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> 'c -> 'c
val for_all : ('a -> bool) -> 'a list -> bool
val exists : ('a -> bool) -> 'a list -> bool
val for_all2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : ('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> 'a list -> bool
val memq : 'a -> 'a list -> bool
val find : ('a -> bool) -> 'a list -> 'a
val find_opt : ('a -> bool) -> 'a list -> 'a option
val find_map : ('a -> 'b option) -> 'a list -> 'b option
val filter : ('a -> bool) -> 'a list -> 'a list
val find_all : ('a -> bool) -> 'a list -> 'a list
val filteri : (int -> 'a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> ('a * 'b) list -> bool
val mem_assq : 'a -> ('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : ('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : ('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : ('a -> 'a -> int) -> 'a list -> 'a list
val merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val to_seq : 'a list -> 'a Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

since
0.11
val map : ('a -> 'b) -> 'a t -> 'b t

map f [a0; a1; …; an] applies function f in turn to a0; a1; …; an. Safe version of List.map.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

l >|= f is the infix version of map with reversed arguments.

since
0.5
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

since
NEXT_RELEASE
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

val filter : ('a -> bool) -> 'a t -> 'a t

filter p l returns all the elements of the list l that satisfy the predicate p. The order of the elements in the input list l is preserved. Safe version of List.filter.

val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold_right f [a1; …; an] b is f a1 (f a2 ( … (f an b) … )). Safe version of List.fold_right.

val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a

fold_while f init l folds until a stop condition via ('a, `Stop) is indicated by the accumulator.

since
0.8
val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map f init l is a fold_left-like function, but it also maps the list to another list.

since
0.14
val fold_map_i : ('acc -> int -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list

fold_map_i f init l is a foldi-like function, but it also maps the list to another list.

since
2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> 'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce init l combines map f and fold_left reduce init in one operation.

since
2.8
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list

scan_left f init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val reduce : ('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

since
3.2
val reduce_exn : ('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

raises Invalid_argument

if the given list is empty.

since
3.2
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 f init l1 l2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : ('acc -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map f init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_filter_map_i : ('acc -> int -> 'a -> 'acc * 'b option) -> 'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i f init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

since
2.8
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val fold_flat_map_i : ('acc -> int -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i f init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
2.8
val count : ('a -> bool) -> 'a list -> int

count p l counts how many elements of l satisfy predicate p.

since
1.5, but only
since
2.2 with labels
val count_true_false : ('a -> bool) -> 'a list -> int * int

count_true_false p l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate p, and int2 the number of elements that do not satisfy p.

since
2.4
val init : int -> (int -> 'a) -> 'a t

init len f is f 0; f 1; …; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

since
3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

val flat_map : ('a -> 'b t) -> 'a t -> 'b t

flat_map f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

val flat_map_i : (int -> 'a -> 'b t) -> 'a t -> 'b t

flat_map_i f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

since
2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

val product : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

product comb l1 l2 computes the cartesian product of the two lists, with the given combinator comb.

val fold_product : ('c -> 'a -> 'b -> 'c) -> 'c -> 'a t -> 'b t -> 'c

fold_product f init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1]; [l2]; …; [ln]] produces the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
 [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
 # cartesian_product [[1;2];[];[4;5;6]] = [];;
 # cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =
diff --git a/dev/containers/CCListLabels/index.html b/dev/containers/CCListLabels/index.html
index b048d5d2..8265a78c 100644
--- a/dev/containers/CCListLabels/index.html
+++ b/dev/containers/CCListLabels/index.html
@@ -1,5 +1,5 @@
 
-CCListLabels (containers.CCListLabels)

Module CCListLabels

Complements to list

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a

Documentation for the standard ListLabels module

include module type of Stdlib.ListLabels
type !'a t = 'a list =
| ([])
| (::) of 'a * 'a list
val length : 'a list -> int
val hd : 'a list -> 'a
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> len:int -> int
val cons : 'a -> 'a list -> 'a list
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : len:int -> f:(int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : f:('a -> unit) -> 'a list -> unit
val iteri : f:(int -> 'a -> unit) -> 'a list -> unit
val map : f:('a -> 'b) -> 'a list -> 'b list
val mapi : f:(int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : f:('a -> 'b) -> 'a list -> 'b list
val filter_map : f:('a -> 'b option) -> 'a list -> 'b list
val concat_map : f:('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b list -> 'a * 'c list
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b list -> 'a
val fold_right : f:('a -> 'b -> 'b) -> 'a list -> init:'b -> 'b
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b list -> 'c list -> 'a
val fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> init:'c -> 'c
val for_all : f:('a -> bool) -> 'a list -> bool
val exists : f:('a -> bool) -> 'a list -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> set:'a list -> bool
val memq : 'a -> set:'a list -> bool
val find : f:('a -> bool) -> 'a list -> 'a
val find_opt : f:('a -> bool) -> 'a list -> 'a option
val find_map : f:('a -> 'b option) -> 'a list -> 'b option
val filter : f:('a -> bool) -> 'a list -> 'a list
val find_all : f:('a -> bool) -> 'a list -> 'a list
val filteri : f:(int -> 'a -> bool) -> 'a list -> 'a list
val partition : f:('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> map:('a * 'b) list -> bool
val mem_assq : 'a -> map:('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val to_seq : 'a list -> 'a Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

since
0.11
val map : f:('a -> 'b) -> 'a t -> 'b t

map ~f [a0; a1; …; an] applies function f in turn to [a0; a1; …; an]. Safe version of List.map.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

l >|= f is the infix version of map with reversed arguments.

since
0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

since
0.12
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

val filter : f:('a -> bool) -> 'a t -> 'a t

filter ~f l returns all the elements of the list l that satisfy the predicate f. The order of the elements in the input list l is preserved. Safe version of List.filter.

val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b

fold_right ~f [a1; …; an] ~init is f a1 (f a2 ( … (f an init) … )). Safe version of List.fold_right.

val fold_while : f:('a -> 'b -> 'a * [ `Stop | `Continue ]) -> init:'a -> 'b t -> 'a

fold_while ~f ~init l folds until a stop condition via ('a, `Stop) is indicated by the accumulator.

since
0.8
val fold_map : f:('acc -> 'a -> 'acc * 'b) -> init:'acc -> 'a list -> 'acc * 'b list

fold_map ~f ~init l is a fold_left-like function, but it also maps the list to another list.

since
0.14
val fold_map_i : f:('acc -> int -> 'a -> 'acc * 'b) -> init:'acc -> 'a list -> 'acc * 'b list

fold_map_i ~f ~init l is a foldi-like function, but it also maps the list to another list.

since
2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> init:'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce ~init l combines map ~f and fold_left ~reduce ~init in one operation.

since
2.8
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list

scan_left ~f ~init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val reduce : f:('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

since
3.2
val reduce_exn : f:('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

raises Invalid_argument

if the given list is empty.

since
3.2
val fold_map2 : f:('acc -> 'a -> 'b -> 'acc * 'c) -> init:'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 ~f ~init l1 l2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : f:('acc -> 'a -> 'acc * 'b option) -> init:'acc -> 'a list -> 'acc * 'b list

fold_filter_map ~f ~init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_filter_map_i : f:('acc -> int -> 'a -> 'acc * 'b option) -> init:'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i ~f ~init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

since
2.8
val fold_flat_map : f:('acc -> 'a -> 'acc * 'b list) -> init:'acc -> 'a list -> 'acc * 'b list

fold_flat_map ~f ~init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val fold_flat_map_i : f:('acc -> int -> 'a -> 'acc * 'b list) -> init:'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i ~f ~init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
2.8
val count : f:('a -> bool) -> 'a list -> int

count ~f l counts how many elements of l satisfy predicate f.

since
1.5, but only
since
2.2 with labels
val count_true_false : f:('a -> bool) -> 'a list -> int * int

count_true_false ~f l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate f, and int2 the number of elements that do not satisfy f.

since
2.4
val init : int -> f:(int -> 'a) -> 'a t

init len ~f is f 0; f 1; …; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

since
3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

val flat_map : f:('a -> 'b t) -> 'a t -> 'b t

flat_map ~f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

val flat_map_i : f:(int -> 'a -> 'b t) -> 'a t -> 'b t

flat_map_i ~f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

since
2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

val product : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

product ~f l1 l2 computes the cartesian product of the two lists, with the given combinator f.

val fold_product : f:('c -> 'a -> 'b -> 'c) -> init:'c -> 'a t -> 'b t -> 'c

fold_product ~f ~init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1];[l2]; …; [ln]] produces the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
+CCListLabels (containers.CCListLabels)

Module CCListLabels

Complements to list

type 'a iter = ('a -> unit) -> unit

Fast internal iterator.

since
2.8
type 'a gen = unit -> 'a option
type 'a printer = Stdlib.Format.formatter -> 'a -> unit
type 'a random_gen = Stdlib.Random.State.t -> 'a

Documentation for the standard ListLabels module

include module type of Stdlib.ListLabels
type !'a t = 'a list =
| ([])
| (::) of 'a * 'a list
val length : 'a list -> int
val hd : 'a list -> 'a
val compare_lengths : 'a list -> 'b list -> int
val compare_length_with : 'a list -> len:int -> int
val cons : 'a -> 'a list -> 'a list
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
val nth_opt : 'a list -> int -> 'a option
val rev : 'a list -> 'a list
val init : len:int -> f:(int -> 'a) -> 'a list
val append : 'a list -> 'a list -> 'a list
val rev_append : 'a list -> 'a list -> 'a list
val concat : 'a list list -> 'a list
val flatten : 'a list list -> 'a list
val iter : f:('a -> unit) -> 'a list -> unit
val iteri : f:(int -> 'a -> unit) -> 'a list -> unit
val map : f:('a -> 'b) -> 'a list -> 'b list
val mapi : f:(int -> 'a -> 'b) -> 'a list -> 'b list
val rev_map : f:('a -> 'b) -> 'a list -> 'b list
val filter_map : f:('a -> 'b option) -> 'a list -> 'b list
val concat_map : f:('a -> 'b list) -> 'a list -> 'b list
val fold_left_map : f:('a -> 'b -> 'a * 'c) -> init:'a -> 'b list -> 'a * 'c list
val fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b list -> 'a
val fold_right : f:('a -> 'b -> 'b) -> 'a list -> init:'b -> 'b
val iter2 : f:('a -> 'b -> unit) -> 'a list -> 'b list -> unit
val map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val rev_map2 : f:('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b list -> 'c list -> 'a
val fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a list -> 'b list -> init:'c -> 'c
val for_all : f:('a -> bool) -> 'a list -> bool
val exists : f:('a -> bool) -> 'a list -> bool
val for_all2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val exists2 : f:('a -> 'b -> bool) -> 'a list -> 'b list -> bool
val mem : 'a -> set:'a list -> bool
val memq : 'a -> set:'a list -> bool
val find : f:('a -> bool) -> 'a list -> 'a
val find_opt : f:('a -> bool) -> 'a list -> 'a option
val find_map : f:('a -> 'b option) -> 'a list -> 'b option
val filter : f:('a -> bool) -> 'a list -> 'a list
val find_all : f:('a -> bool) -> 'a list -> 'a list
val filteri : f:(int -> 'a -> bool) -> 'a list -> 'a list
val partition : f:('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assoc_opt : 'a -> ('a * 'b) list -> 'b option
val assq : 'a -> ('a * 'b) list -> 'b
val assq_opt : 'a -> ('a * 'b) list -> 'b option
val mem_assoc : 'a -> map:('a * 'b) list -> bool
val mem_assq : 'a -> map:('a * 'b) list -> bool
val remove_assoc : 'a -> ('a * 'b) list -> ('a * 'b) list
val remove_assq : 'a -> ('a * 'b) list -> ('a * 'b) list
val split : ('a * 'b) list -> 'a list * 'b list
val combine : 'a list -> 'b list -> ('a * 'b) list
val sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val stable_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val fast_sort : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val sort_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list
val merge : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val to_seq : 'a list -> 'a Stdlib.Seq.t
val of_seq : 'a Stdlib.Seq.t -> 'a list
type 'a t = 'a list
val empty : 'a t

empty is [].

val is_empty : _ t -> bool

is_empty l returns true iff l = [].

since
0.11
val map : f:('a -> 'b) -> 'a t -> 'b t

map ~f [a0; a1; …; an] applies function f in turn to [a0; a1; …; an]. Safe version of List.map.

val (>|=) : 'a t -> ('a -> 'b) -> 'b t

l >|= f is the infix version of map with reversed arguments.

since
0.5
val cons : 'a -> 'a t -> 'a t

cons x l is x::l.

since
0.12
val append : 'a t -> 'a t -> 'a t

append l1 l2 returns the list that is the concatenation of l1 and l2. Safe version of List.append.

val cons' : 'a t -> 'a -> 'a t

cons' l x is the same as x :: l. This is convenient for fold functions such as List.fold_left or Array.fold_left.

since
NEXT_RELEASE
val cons_maybe : 'a option -> 'a t -> 'a t

cons_maybe (Some x) l is x :: l. cons_maybe None l is l.

since
0.13
val (@) : 'a t -> 'a t -> 'a t

l1 @ l2 is like append l1 l2. Concatenate the two lists l1 and l2.

val filter : f:('a -> bool) -> 'a t -> 'a t

filter ~f l returns all the elements of the list l that satisfy the predicate f. The order of the elements in the input list l is preserved. Safe version of List.filter.

val fold_right : f:('a -> 'b -> 'b) -> 'a t -> init:'b -> 'b

fold_right ~f [a1; …; an] ~init is f a1 (f a2 ( … (f an init) … )). Safe version of List.fold_right.

val fold_while : f:('a -> 'b -> 'a * [ `Stop | `Continue ]) -> init:'a -> 'b t -> 'a

fold_while ~f ~init l folds until a stop condition via ('a, `Stop) is indicated by the accumulator.

since
0.8
val fold_map : f:('acc -> 'a -> 'acc * 'b) -> init:'acc -> 'a list -> 'acc * 'b list

fold_map ~f ~init l is a fold_left-like function, but it also maps the list to another list.

since
0.14
val fold_map_i : f:('acc -> int -> 'a -> 'acc * 'b) -> init:'acc -> 'a list -> 'acc * 'b list

fold_map_i ~f ~init l is a foldi-like function, but it also maps the list to another list.

since
2.8
val fold_on_map : f:('a -> 'b) -> reduce:('acc -> 'b -> 'acc) -> init:'acc -> 'a list -> 'acc

fold_on_map ~f ~reduce ~init l combines map ~f and fold_left ~reduce ~init in one operation.

since
2.8
val scan_left : f:('acc -> 'a -> 'acc) -> init:'acc -> 'a list -> 'acc list

scan_left ~f ~init l returns the list [init; f init x0; f (f init x0) x1; …] where x0, x1, etc. are the elements of l.

since
1.2, but only
since
2.2 with labels
val reduce : f:('a -> 'a -> 'a) -> 'a list -> 'a option

reduce f (hd::tl) returns Some (fold_left f hd tl). If l is empty, then None is returned.

since
3.2
val reduce_exn : f:('a -> 'a -> 'a) -> 'a list -> 'a

reduce_exn is the unsafe version of reduce.

raises Invalid_argument

if the given list is empty.

since
3.2
val fold_map2 : f:('acc -> 'a -> 'b -> 'acc * 'c) -> init:'acc -> 'a list -> 'b list -> 'acc * 'c list

fold_map2 ~f ~init l1 l2 is to fold_map what List.map2 is to List.map.

raises Invalid_argument

if the lists do not have the same length.

since
0.16
val fold_filter_map : f:('acc -> 'a -> 'acc * 'b option) -> init:'acc -> 'a list -> 'acc * 'b list

fold_filter_map ~f ~init l is a fold_left-like function, but also generates a list of output in a way similar to filter_map.

since
0.17
val fold_filter_map_i : f:('acc -> int -> 'a -> 'acc * 'b option) -> init:'acc -> 'a list -> 'acc * 'b list

fold_filter_map_i ~f ~init l is a foldi-like function, but also generates a list of output in a way similar to filter_map.

since
2.8
val fold_flat_map : f:('acc -> 'a -> 'acc * 'b list) -> init:'acc -> 'a list -> 'acc * 'b list

fold_flat_map ~f ~init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
0.14
val fold_flat_map_i : f:('acc -> int -> 'a -> 'acc * 'b list) -> init:'acc -> 'a list -> 'acc * 'b list

fold_flat_map_i ~f ~init l is a fold_left-like function, but it also maps the list to a list of lists that is then flatten'd.

since
2.8
val count : f:('a -> bool) -> 'a list -> int

count ~f l counts how many elements of l satisfy predicate f.

since
1.5, but only
since
2.2 with labels
val count_true_false : f:('a -> bool) -> 'a list -> int * int

count_true_false ~f l returns a pair (int1,int2) where int1 is the number of elements in l that satisfy the predicate f, and int2 the number of elements that do not satisfy f.

since
2.4
val init : int -> f:(int -> 'a) -> 'a t

init len ~f is f 0; f 1; …; f (len-1).

raises Invalid_argument

if len < 0.

since
0.6
val combine : 'a list -> 'b list -> ('a * 'b) list

combine [a1; …; an] [b1; …; bn] is [(a1,b1); …; (an,bn)]. Transform two lists into a list of pairs. Like List.combine but tail-recursive.

raises Invalid_argument

if the lists have distinct lengths.

since
1.2, but only
since
2.2 with labels
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen

combine_gen l1 l2 transforms two lists into a gen of pairs. Lazy version of combine. Unlike combine, it does not fail if the lists have different lengths; instead, the output has as many pairs as the smallest input list.

since
1.2, but only
since
2.2 with labels
val combine_shortest : 'a list -> 'b list -> ('a * 'b) list

combine_shortest [a1; …; am] [b1; …; bn] is [(a1,b1); …; (am,bm)] if m <= n. Like combine but stops at the shortest list rather than raising.

since
3.1
val split : ('a * 'b) t -> 'a t * 'b t

split [(a1,b1); …; (an,bn)] is ([a1; …; an], [b1; …; bn]). Transform a list of pairs into a pair of lists. A tail-recursive version of List.split.

since
1.2, but only
since
2.2 with labels
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int

compare cmp l1 l2 compares the two lists l1 and l2 using the given comparison function cmp.

val compare_lengths : 'a t -> 'b t -> int

compare_lengths l1 l2 compare the lengths of the two lists l1 and l2. Equivalent to compare (length l1) (length l2) but more efficient.

since
1.5, but only
since
2.2 with labels
val compare_length_with : 'a t -> int -> int

compare_length_with l x compares the length of the list l to an integer x. Equivalent to compare (length l) x but more efficient.

since
1.5, but only
since
2.2 with labels
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool

equal p l1 l2 returns true if l1 and l2 are equal.

val flat_map : f:('a -> 'b t) -> 'a t -> 'b t

flat_map ~f l maps and flattens at the same time (safe). Evaluation order is not guaranteed.

val flat_map_i : f:(int -> 'a -> 'b t) -> 'a t -> 'b t

flat_map_i ~f l maps with index and flattens at the same time (safe). Evaluation order is not guaranteed.

since
2.8
val flatten : 'a t t -> 'a t

flatten [l1]; [l2]; … concatenates a list of lists. Safe version of List.flatten.

val product : f:('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t

product ~f l1 l2 computes the cartesian product of the two lists, with the given combinator f.

val fold_product : f:('c -> 'a -> 'b -> 'c) -> init:'c -> 'a t -> 'b t -> 'c

fold_product ~f ~init l1 l2 applies the function f with the accumulator init on all the pair of elements of l1 and l2. Fold on the cartesian product.

val cartesian_product : 'a t t -> 'a t t

cartesian_product [[l1];[l2]; …; [ln]] produces the cartesian product of this list of lists, by returning all the ways of picking one element per sublist. NOTE the order of the returned list is unspecified. For example:

# cartesian_product [[1;2];[3];[4;5;6]] |> sort =
 [[1;3;4];[1;3;5];[1;3;6];[2;3;4];[2;3;5];[2;3;6]];;
 # cartesian_product [[1;2];[];[4;5;6]] = [];;
 # cartesian_product [[1;2];[3];[4];[5];[6]] |> sort =