module MzList: sig .. end
A bunch of useful functions for lists.
val map2i : (int -> 'a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
Same as map2 but pass an extra parameter that represents the index
val fold_righti : (int -> 'elt -> 'acc -> 'acc) -> 'elt list -> 'acc -> 'acc
Same as fold_right except that the function takes the current index in the
list. The index starts counting from the right of the list, so the first call
will pass 0 for i.
val fold_lefti : (int -> 'acc -> 'elt -> 'acc) -> 'acc -> 'elt list -> 'acc
Same as fold_left except that the function takes the current index in the
list
val fold_left2i : (int -> 'acc -> 'b -> 'c -> 'acc) -> 'acc -> 'b list -> 'c list -> 'acc
Same as fold_left2 except that the function takes the current index in the
list
val fold_left3 : ('acc -> 't1 -> 't2 -> 't3 -> 'acc) ->
'acc -> 't1 list -> 't2 list -> 't3 list -> 'acc
Same as fold_left2 but with three lists.
val reduce : ('a -> 'a -> 'a) -> 'a list -> 'a
Same as fold_left, but start folding on the head of the list instead of
giving an initial element.
val iter2i : (int -> 'a -> 'b -> unit) -> 'a list -> 'b list -> unit
Same as List.iteri but with two lists.
val iter3 : ('a -> 'b -> 'c -> unit) -> 'a list -> 'b list -> 'c list -> unit
Same as List.iter but with three lists.
val combine3 : 'a list -> 'b list -> 'c list -> ('a * 'b * 'c) list
Same as List.combine but for triples instead of pairs.
val split3 : ('a * 'b * 'c) list -> 'a list * 'b list * 'c list
Same as List.split but for triples instead of pairs.
val make : int -> (int -> 'a) -> 'a list
make n f creates [f 1; ...; f n].
val last : 'a list -> 'a
Get the last element of a list.
val ignore_map : ('a -> 'b) -> 'a list -> unit
Map a function and then discard the result.
val check_for_duplicates : ('a -> 'a -> int) -> 'a list -> ('a * 'a) option
Checking for duplicates in a list. check_for_duplicates compare xs returns either
Some (x1, x2) where x1 and x2 are distinct elements of the list xs such
that compare x1 x2 is zero, or None, if no such two elements exist.
val max : int list -> int
Find the biggest element in a list
val filter_some : 'a option list -> 'a list
Turns [Some a; None; ...] into [a; ...]
val nth_opt : 'a list -> int -> 'a option
Just like List.nth except it returns an Option type.
val map_some : ('a -> 'b option) -> 'a list -> 'b list
Map and discard some elements at the same time.
val index : ('a -> bool) -> 'a list -> int
Find the index of the first element in a list that satisfies a predicate.
val take : ('a -> 'b option) -> 'a list -> ('a list * ('a * 'b)) option
If f may convert an 'a into a 'b, then take f l returns the first
convertible element in the list, along with the remaining elements in the
list.
val take_bool : ('a -> bool) -> 'a list -> ('a list * 'a) option
val find_opt : ('a -> 'b option) -> 'a list -> 'b option
val map_flatten : ('a -> 'b list) -> 'a list -> 'b list
val cut : int -> 'a list -> 'a list
val equal : ('a -> 'a -> bool) -> 'a list -> 'a list -> bool
Equality of lists, up to equality of elements.
val cps_map : ('a -> ('b -> 'c) -> 'c) -> 'a list -> ('b list -> 'c) -> 'c
A CPS version of List.map.