package tezos-stdlib

  1. Overview
  2. Docs
val is_empty : 'a list -> bool

is_empty l returns true iff l = [].

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

remove nb list remove the first nb elements from the list list.

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

repeat n x is a list of n x's

val shift : 'a list -> 'a list

shift (hd :: tl) computes tl @ [hd]

val product : 'a list -> 'b list -> ('a * 'b) list

product a b computes the Cartesian product of two lists a and b.

val take_n : ?compare:('a -> 'a -> int) -> int -> 'a list -> 'a list

take_n n l returns the n first elements of l. When compare is provided, it returns the n greatest element of l.

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

drop_n n l returns the suffix of l after the first n elements, or if n > length l.

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

split_n n l is a pair of lists (j, k) where j contains the n first elements of l and k the remainder elements. If l has less than or exactly n elements, j is l and k is [].

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

select n l is (nth element of l, l without that element)

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

rev_sub l n is List.rev l capped to max n elements

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

sub l n is l capped to max n elements

val shuffle : ?rng_state:Stdlib.Random.State.t -> 'a list -> 'a list

shuffle l is a list that contains the same elements as l but in a random order.

val index_of : ?compare:('a -> 'a -> int) -> 'a -> 'a list -> int option

Get the index of an element in a list.

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

filter_some l returns all Some elements of l

val find_map : ('a -> 'b option) -> 'a list -> 'b 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.

Present in OCaml 4.10: this function can be removed once we catch up.

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

fold_left_i f init l is equivalent to fold_left except that the index of the element is passed as a first argument to f.

OCaml

Innovation. Community. Security.