package tezos-stdlib

  1. Overview
  2. Docs
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 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 [].

module Bounded (E : Stdlib.Set.OrderedType) : sig ... end

Bounded sequence: keep only the n greatest elements.

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 merge_filter2 : ?finalize:('a list -> 'a list) -> ?compare:('a -> 'a -> int) -> ?f:('a option -> 'a option -> 'a option) -> 'a list -> 'a list -> 'a list

merge_filter2 ~compare ~f l1 l2 merges two lists ordered by compare and whose items can be merged with f. Item is discarded or kept whether f returns Some or None

val merge2 : ?finalize:('a list -> 'a list) -> ?compare:('a -> 'a -> int) -> ?f:('a -> 'a -> 'a) -> 'a list -> 'a list -> 'a list

merge2 ~compare ~f l1 l2 merges two lists ordered by compare and whose items can be merged with f

val shuffle : '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.

OCaml

Innovation. Community. Security.