list
Lists
type 'elt t = 'elt list
The type `t` is an alias for the predefined type `list`.val empty : 'elt.'elt t
The value empty is the empty list. It is a synonym for
[]. In some contexts, it is useful to annotate it with its type,
for example: (empty : int list).
val length : 'elt.'elt t -> nat
The call length l is the number of elements in the list
l. Note: List.length is another name for List.size.
val size : 'elt.'elt t -> nat
The call size l is the number of elements in the list l.
val head : 'elt.'elt t -> 'elt option
The call head l, where l is a list, is None if l is
empty; otherwise, Some hd, where hd is the head of the list.
val head_opt : 'elt.'elt t -> 'elt option
**Deprecated:** Use `List.head` instead.The call head_opt l, where l is a list, is None if l is
empty; otherwise, Some hd, where hd is the head of the list.
val tail : 'elt.'elt t -> 'elt t option
The call tail l, where l is a list, is None if l is
empty; otherwise, Some tl, where tl is the tail of the list.
val tail_opt : 'elt.'elt t -> 'elt t option
**Deprecated:** Use `List.tail` instead.The call tail_opt l, where l is a list, is None if l is
empty; otherwise, Some tl, where tl is the tail of the list.
val map : 'src 'dst.('src -> 'dst) -> 'src list -> 'dst list
The call map f [a1; ...; an] applies the function f to a1,
..., an (from left to right), and builds the list
[f a1; ...; f an] with the results returned by f.
val iter : 'elt.('elt -> unit) -> 'elt t -> unit
The call iter f [a1; ...; an] applies the function f in turn
to [a1; ...; an]. It is equivalent to
let () = f a1 in let () = f a2 in ... in f an.
val fold_left : 'elt 'acc.(('acc * 'elt) -> 'acc) -> 'acc -> 'elt t -> 'acc
The call fold_left f init [a1; ...; an] is
f (... (f (f init a1) a2) ...) an.
val fold_right : 'elt 'acc.(('elt * 'acc) -> 'acc) -> 'elt t -> 'acc -> 'acc
The call fold_right f [a1; ...; an] init is
f a1 (f a2 (... (f an init) ...)).
val fold : 'elt 'acc.(('acc * 'elt) -> 'acc) -> 'elt t -> 'acc -> 'acc
The call fold f [a1; ...; an] init is
f (... (f (f init a1) a2) ...) an. Note:
fold_left f init list is the same as fold f list init.
val cons : 'elt.'elt -> 'elt t -> 'elt t
The call cons e l is e :: l.
val find_opt : 'elt.('elt -> bool) -> 'elt t -> 'elt option
The call find_opt pred list is None if no element of the
list list satisfies the predicate pred; otherwise, it is
Some e, where e is the leftmost element in list that satisfies
pred. The order of the calls of pred is not specified.
val filter_map : 'src 'dst.('src -> 'dst option) -> 'src list -> 'dst list
The call filter_map f l is the maximal sub-list of l such
that the call of function f on its elements is not None. Note:
f is called on all elements of l. The order of the calls of
f is not specified.
val update : 'elt.('elt -> 'elt option) -> 'elt t -> 'elt t
The call update f l is the list l where the elements e
such that f e is Some v have been replaced by v.
val update_with : 'elt.('elt -> bool) -> 'elt -> 'elt t -> 'elt t
The call update_with p d l is the list l where the elements
e such that satisfy the predicate p are replaced by d.