package lambdapi

  1. Overview
  2. Docs
module L = Stdlib.List
include module type of struct include L end
type !'a t = 'a list =
  1. | []
  2. | :: 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 is_empty : 'a list -> bool
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 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 equal : ('a -> 'a -> bool) -> 'a list -> 'a list -> bool
val compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int
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 fold_left_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list
val fold_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc
val fold_right : ('a -> 'acc -> 'acc) -> 'a list -> 'acc -> 'acc
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 : ('acc -> 'a -> 'b -> 'acc) -> 'acc -> 'a list -> 'b list -> 'acc
val fold_right2 : ('a -> 'b -> 'acc -> 'acc) -> 'a list -> 'b list -> 'acc -> 'acc
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_index : ('a -> bool) -> 'a list -> int option
val find_mapi : (int -> '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 partition_map : ('a -> ('b, 'c) Stdlib.Either.t) -> 'a list -> 'b list * 'c 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 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
val zip : 'a list -> 'b list -> ('a * 'b) list
val unzip : ('a * 'b) list -> 'a list * 'b list
val pp : 'a Base.pp -> unit Base.outfmt -> 'a list Base.pp

pp elt sep ppf l prints the list l on the formatter ppf using sep as separator, and elt for printing the elements.

val cmp : 'a Base.cmp -> 'a list Base.cmp

Total order on lists.

val eq : 'a Base.eq -> 'a list Base.eq

eq eq_elt l1 l2 tests the equality of l1 and l2, comparing their elements with eq_elt.

val find_map : ('a -> 'b option) -> 'c t -> 'd option

find_map f l applies f to the elements of l in order, and returns the first result of the form Some v, or None if none exist.

  • since 4.10.0
val filter_map : ('a -> 'b option) -> 'a list -> 'b list

filter_map f l applies f to every element of l, filters out the None elements and returns the list of the arguments of the Some elements.

  • since 4.08.0
val concat_map : ('a -> 'b list) -> 'a t -> 'b list

concat_map f l gives the same result as concat (map f l). Tail-recursive.

  • since 4.10.0
val filter_rev_map : ('a -> 'b option) -> 'a list -> 'b list

filter_rev_map f l is equivalent to filter_map f (List.rev l), but it only traverses the list once and is tail-recursive.

val filteri_map : (int -> 'a -> 'b option) -> 'a list -> 'b list

filteri_map f l applies f element wise on l and keeps x such that for e in l, f e = Some(x).

val cut : 'a list -> int -> 'a list * 'a list

cut l k returns a pair of lists (l1, l2) such that l1 has length min (List.length l) k and l1 @ l2 is equal to l.

val add_array2 : 'a array -> 'b array -> ('a * 'b) list -> ('a * 'b) list

add_array a1 a2 l returns a list containing the elements of l, and the (corresponding) elements of a1 and a2. Note that a1 and a2 should have the same lenght otherwise Invalid_argument is raised.

val same_length : 'a list -> 'b list -> bool

same_length l1 l2 returns true whenever l1 and l2 are lists of the same length. The function stops as soon as possible.

val max : ?cmp:('a -> 'a -> int) -> 'a list -> 'a

max ?cmp l finds the max of list l with compare function ?cmp defaulting to Stdlib.compare.

  • raises Invalid_argument

    if l is empty.

val assoc_eq : 'a Base.eq -> 'a -> ('a * 'b) list -> 'b

assoc_eq e k l is List.assoc k l with equality function e.

  • raises Not_found

    if k is not a key of l.

val remove_phys_dups : 'a list -> 'a0 t

remove_phys_dups l uniqify list l keeping only the last element, using physical equality.

val destruct : 'a list -> int -> 'a list * 'a * 'a list

destruct l i returns a triple (left_rev, e, right) where e is the i-th element of l, left_rev is the reversed prefix of l up to its i-th element (excluded), and right is the remaining suffix of l (starting at its i+1-th element).

  • raises Invalid_argument

    when i < 0.

  • raises Not_found

    when i ≥ length v.

val reconstruct : 'a list -> 'a list -> 'a list -> 'a list

reconstruct left_rev l right concatenates (reversed) left_rev, l and right. This function will typically be used in combination with destruct to insert a sublist l in the place of the element at the specified position in the specified list.

val init : int -> (int -> 'a) -> 'a list

init n f creates a list with f 0 up to f n as its elements. Note that Invalid_argument is raised if n is negative.

val mem_sorted : 'a Base.cmp -> 'a -> 'a list -> bool

mem_sorted cmp x l tells whether x is in l assuming that l is sorted wrt cmp.

val insert : 'a Base.cmp -> 'a -> 'a list -> 'a list

insert cmp x l inserts x in the list l assuming that l is sorted in increasing order wrt cmp.

val insert_uniq : 'a Base.cmp -> 'a -> 'a list -> 'a list

insert_uniq cmp x l inserts x in the list l assuming that l is sorted in increasing order wrt cmp, but only if x does not occur in l.

val split_last : 'a list -> 'a list * 'a

split_last l returns (l',x) if l = append l' [x], and

  • raises Invalid_argument

    otherwise.

val rev_mapi : (int -> 'a -> 'b) -> 'c t -> 'd t

rev_mapi f [x1;..;xn] returns f (n-1) xn; ..; f 0 x1.

val swap : int -> 'a list -> 'a list

swap i xs put the i-th element (counted from 0) of xs at the head.

  • raises Invalid_argument

    if the i-th element does not exist.

val fold_left_while : ('a -> 'b -> 'c) -> ('d -> bool) -> 'e -> 'f t -> 'g

fold_left_while f cond a [b1 b2 ..] computes (f..(f (f a b1) b2)..bm) where cond is true for b1..bm and false for b_m+1 or bm is last element

val remove_first : ('a -> bool) -> 'a list -> 'a list

remove_first f l removes from l the first element satisfying f.

val remove_heads : int -> 'a t -> 'a t

remove_heads n xs remove the min(n,length xs) elements of xs.

val split : ('a -> bool) -> 'a list -> 'a list * 'a * 'a list

split f l returns the tuple (l1,x,l2) such that x is the first element of l satisying f, l1 is the sub-list of l preceding x, and l2 is the sub-list of l following x: l = l1 :: x :: l2.

  • raises Not_found

    if there is no element of l satisying f.

val iter_head_tail : ('a -> 'a list -> unit) -> 'a0 list -> unit

iter_head_tail f l iterates f on all pairs (head, tail) of l.

val sequence_opt : 'a option list -> 'a list option

sequence_opt l is Some [x1; x2; ...] if all elements of l are of the form Some xi, and None if there is a None in l.

val pos : ('a -> bool) -> 'a list -> int

pos f xs returns the position (counting from 0) of the first element of xs which satisfies f, or raise Not_found.