package links

  1. Overview
  2. Docs
On This Page
  1. Lists

Lists

val empty : 'a list -> bool

Test whether the argument is the empty list.

val fromTo : int -> int -> int list

fromTo a b is the list of consecutive integers starting with a and ending with b-1. Throws Invalid_argument "fromTo" if b < a.

val mapIndex : ('a -> int -> 'b) -> 'a list -> 'b list

map with index

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

all_equiv rel list: given an equiv. rel'n rel, determine whether all elements of list are equivalent.

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

span pred list: partition list into an initial sublist satisfying pred and the remainder.

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

groupBy rel list: given a binary rel'n rel, partition list into chunks s.t. successive elements x, y in a chunk give the same value under rel.

val groupByPred : ('a -> 'b) -> 'a list -> 'a list list

groupByPred pred partitions list into chunks where all elements in the chunk give the same value under pred.

val groupByPred' : ('a -> 'b) -> 'a list -> 'a list list

groupByPred': Alternate implementation of groupByPred.

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

unsnoc list: Partition list into its last element and all the others.

  • returns

    (others, lastElem)

val unsnoc_opt : 'a list -> ('a list * 'a) option

unsnoc_opt list: Partition list into its last element and all the others.

  • returns

    Some (others, lastElem) or None if the list is empty.

val last : 'a list -> 'a

last list: Return the last element of a list

val last_opt : 'a list -> 'a option

last_opt list: Return the last element of a list, or None if the list is empty.

val curtail : 'a list -> 'a list

curtail list: Return a copy of the list with the last element removed.

val difference : 'a list -> 'a list -> 'a list
val remove_all : 'a list -> 'a list -> 'a list
val subset : 'a list -> 'a list -> bool
val less_to_cmp : ('a -> 'a -> bool) -> 'a -> 'a -> int

Convert a (bivalent) less-than function into a (three-valued) comparison function.

val has_duplicates : 'a list -> bool

Checks whether list contains duplicates

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

Remove duplicates from a list, using the given relation to determine `duplicates'

val ordered_consecutive : int list -> bool
val drop : int -> 'a list -> 'a list
val take : int -> 'a list -> 'a list
val split : int -> 'a list -> 'a list * 'a list
val remove : 'a -> 'a list -> 'a list
val concat_map : ('a -> 'b list) -> 'a list -> 'b list
val concat_map_uniq : ('a -> 'b list) -> 'a list -> 'b list
val concat_map_undup : ('a -> 'a -> bool) -> ('b -> 'a list) -> 'b list -> 'a list
val for_each : 'a list -> ('a -> unit) -> unit
val push_back : 'a -> 'a list Stdlib.ref -> unit
val push_front : 'a -> 'a list Stdlib.ref -> unit
val split3 : ('a * 'b * 'c) list -> 'a list * 'b list * 'c list
val split4 : ('a * 'b * 'c * 'd) list -> 'a list * 'b list * 'c list * 'd list
val drop_nth : 'a list -> int -> 'a list
val filter_map : ('a -> bool) -> ('a -> 'b) -> 'a list -> 'b list
val map_filter : ('a -> 'b) -> ('b -> bool) -> 'a list -> 'b list
val print_list : string list -> string
val zip : 'a list -> 'b list -> ('a * 'b) list
val zip_with : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val split_with : ('a -> 'b * 'c) -> 'a list -> 'b list * 'c list
exception Lists_length_mismatch
val zip' : 'a list -> 'b list -> ('a * 'b) list
val zip_with' : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
val transpose : 'a list list -> 'a list list
OCaml

Innovation. Community. Security.