Module Ext.List

module List: sig .. end
Standard Ocaml List module with extended functionality.


Extended functionality

val range : int -> int list
range n creates a list with values from 0 to n-1.
val wrap : 'a -> 'a list
wrap x returns a list that contains x.
val cons : 'a -> 'a list -> 'a list
cons x l appends the value x to the list l. x is the head of the result list.
val remove_fast : 'a -> 'a list -> 'a list
remove_fast x l removes the value x from the list l.
val sum : int list -> int
sum l return the sum of the elements of the int list l.
val sumf : float list -> float
sum l returns the sum of the elements of the float list l.
val sum_map : ('a -> int) -> 'a list -> int
sum_map f l applies the function f on each element of the int list l and then returns the sum of the results.
val sumf_map : ('a -> float) -> 'a list -> float
sumf_map f l applies the function f on each element of the float list l and then returns the sum of the results.
val count : ('a -> bool) -> 'a list -> int
count f l applies boolean the function f on each element of the list l, and returns the number of times that f returns true.
val rev_iter : ('a -> unit) -> 'a list -> unit
rev_iter f l is the same as iter f l, but iterates from right to left.
val iter3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> unit
iter2 f [a1; ...; an] [b1; ...; bn] [c1; ...; c_n] calls in turn f a1 b1 c1; ...; f an bn cn] .
val map3 : ('a -> 'b -> 'c -> 'd) -> 'a list -> 'b list -> 'c list -> 'd list
map f [a1; ...; an] [b1; ...; bn] [c1; ...; c_n] returns the list f a1 b1 c1; ...; f an bn cn. Not tail-recursive.
val split3 : ('a * 'b * 'c) list -> 'a list * 'b list * 'c list
Transform a list of triples into a triple of lists: split3 [(a1,b1,c1); ...; (an,bn,cn)] is ([a1; ...; an], [b1; ...; bn]). Not tail-recursive.
val transpose : 'a list list -> 'a list list
transpose m transposes the matrix m represented as a list of lists.
val rem_first : 'a list -> 'a list
rem_first l returns the tail of the list l.
val rem_item : 'a list -> 'a -> 'a list
rem_item l i returns a list that has the same order as the list l, which does not include the value i. Not tail-recursive.

Functions from the original List module

val length : 'a list -> int
val hd : 'a list -> 'a
val tl : 'a list -> 'a list
val nth : 'a list -> int -> 'a
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 iter : ('a -> unit) -> 'a list -> unit
val iteri : (int -> 'a -> unit) -> 'a list -> unit
val map : ('a -> 'b) -> 'a list -> 'b list
val rev_map : ('a -> 'b) -> 'a list -> 'b 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_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 filter : ('a -> bool) -> 'a list -> 'a list
val find_all : ('a -> bool) -> 'a list -> 'a list
val partition : ('a -> bool) -> 'a list -> 'a list * 'a list
val assoc : 'a -> ('a * 'b) list -> 'b
val assq : 'a -> ('a * 'b) list -> 'b
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 merge : ('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val mapi : (int -> 'a -> 'b) -> 'a list -> 'b list
val fold_left2 : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a