package tezos-protocol-environment

  1. Overview
  2. Docs
Interface layer between the protocols and the shell

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-16.0.tar.gz
sha256=ad9e08819871c75ba6f4530b125f7d157799398e4d77a1e6bfea9d91ff37ff55
sha512=c5dc4d40cc09bc6980fbbdb5c2e105bf4252cf9cfcb2b49660b0ebe4dc789f6709ec3b3bf2f87d81580d3eed9521eeb1c960f24d9b14eb0285aaba1f84d10a9b

doc/tezos-protocol-environment.structs/Tezos_protocol_environment_structs/V7/Array/index.html

Module V7.ArraySource

include module type of struct include Array end
Sourcetype 'a t = 'a array

An alias for the type of arrays.

Sourceval length : 'a array -> int

Return the length (number of elements) of the given array.

Sourceval init : int -> (int -> 'a) -> 'a array

init n f returns a fresh array of length n, with element number i initialized to the result of f i. In other terms, init n f tabulates the results of f applied to the integers 0 to n-1.

  • raises Invalid_argument

    if n < 0 or n > Sys.max_array_length. If the return type of f is float, then the maximum size is only Sys.max_array_length / 2.

Sourceval create_matrix : int -> int -> 'a -> 'a array array
Sourceval append : 'a array -> 'a array -> 'a array

append v1 v2 returns a fresh array containing the concatenation of the arrays v1 and v2.

Sourceval concat : 'a array list -> 'a array

Same as append, but concatenates a list of arrays.

Sourceval copy : 'a array -> 'a array

copy a returns a copy of a, that is, a fresh array containing the same elements as a.

Sourceval to_list : 'a array -> 'a list

to_list a returns the list of all the elements of a.

Sourceval of_list : 'a list -> 'a array

of_list l returns a fresh array containing the elements of l.

  • raises Invalid_argument

    if the length of l is greater than Sys.max_array_length.

Iterators

Sourceval iter : ('a -> unit) -> 'a array -> unit

iter f a applies function f in turn to all the elements of a. It is equivalent to f a.(0); f a.(1); ...; f a.(length a - 1); ().

Sourceval iteri : (int -> 'a -> unit) -> 'a array -> unit

Same as iter, but the function is applied to the index of the element as first argument, and the element itself as second argument.

Sourceval map : ('a -> 'b) -> 'a array -> 'b array

map f a applies function f to all the elements of a, and builds an array with the results returned by f: [| f a.(0); f a.(1); ...; f a.(length a - 1) |].

Sourceval mapi : (int -> 'a -> 'b) -> 'a array -> 'b array

Same as map, but the function is applied to the index of the element as first argument, and the element itself as second argument.

Sourceval fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> 'a

fold_left f init a computes f (... (f (f init a.(0)) a.(1)) ...) a.(n-1), where n is the length of the array a.

Sourceval fold_left_map : ('a -> 'b -> 'a * 'c) -> 'a -> 'b array -> 'a * 'c array

fold_left_map is a combination of fold_left and map that threads an accumulator through calls to f.

  • since 4.13.0
Sourceval fold_right : ('b -> 'a -> 'a) -> 'b array -> 'a -> 'a

fold_right f a init computes f a.(0) (f a.(1) ( ... (f a.(n-1) init) ...)), where n is the length of the array a.

Iterators on two arrays

Array scanning

Sourceval for_all : ('a -> bool) -> 'a array -> bool

for_all f [|a1; ...; an|] checks if all elements of the array satisfy the predicate f. That is, it returns (f a1) && (f a2) && ... && (f an).

  • since 4.03.0
Sourceval exists : ('a -> bool) -> 'a array -> bool

exists f [|a1; ...; an|] checks if at least one element of the array satisfies the predicate f. That is, it returns (f a1) || (f a2) || ... || (f an).

  • since 4.03.0
Sourceval for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool

Same as for_all, but for a two-argument predicate.

  • since 4.11.0
Sourceval exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool

Same as exists, but for a two-argument predicate.

  • since 4.11.0
Sourceval mem : 'a -> 'a array -> bool

mem a set is true if and only if a is structurally equal to an element of l (i.e. there is an x in l such that compare a x = 0).

  • since 4.03.0
Sourceval memq : 'a -> 'a array -> bool

Same as mem, but uses physical equality instead of structural equality to compare list elements.

  • since 4.03.0
Sourceval find_opt : ('a -> bool) -> 'a array -> 'a option

find_opt f a returns the first element of the array a that satisfies the predicate f, or None if there is no value that satisfies f in the array a.

  • since 4.13.0
Sourceval find_map : ('a -> 'b option) -> 'a array -> 'b option

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

  • since 4.13.0

Arrays of pairs

Sourceval split : ('a * 'b) array -> 'a array * 'b array

split [|(a1,b1); ...; (an,bn)|] is ([|a1; ...; an|], [|b1; ...; bn|]).

  • since 4.13.0

Sorting

Arrays and Sequences

Sourceval of_seq : 'a Seq.t -> 'a array

Create an array from the generator

  • since 4.07
Sourceval get : [> `You_cannot_access_array_content_in_the_protocol ]
Sourceval unsafe_get : [> `You_cannot_access_array_content_in_the_protocol ]
Sourceval set : [> `You_cannot_modify_array_content_in_the_protocol ]
Sourceval unsafe_set : [> `You_cannot_modify_array_content_in_the_protocol ]
Sourceval to_seq : [> `You_cannot_traverse_arrays_lazily_in_the_protocol ]
Sourceval to_seqi : [> `You_cannot_traverse_arrays_lazily_in_the_protocol ]
Sourceval make : [> `You_cannot_build_arrays_with_implicit_sharing_in_the_protocol ]
Sourceval create : [> `You_cannot_build_arrays_with_implicit_sharing_in_the_protocol ]
Sourceval make_matrix : [> `You_cannot_build_arrays_with_implicit_sharing_in_the_protocol ]
Sourceval create_float : [> `You_cannot_use_floats_in_the_protocol ]
Sourceval make_float : [> `You_cannot_use_floats_in_the_protocol ]
Sourceval sub : [> `You_cannot_cut_arrays_in_the_protocol ]
Sourceval fill : [> `You_cannot_fill_arrays_in_the_protocol ]
Sourceval blit : [> `You_cannot_blit_arrays_in_the_protocol ]
Sourceval iter2 : [> `You_cannot_traverse_2_arrays_at_once_in_the_protocol ]
Sourceval map2 : [> `You_cannot_traverse_2_arrays_at_once_in_the_protocol ]
Sourceval combine : [> `You_cannot_traverse_2_arrays_at_once_in_the_protocol ]
Sourceval sort : [> `You_cannot_sort_arrays_in_the_protocol ]
Sourceval stable_sort : [> `You_cannot_sort_arrays_in_the_protocol ]
Sourceval fast_sort : [> `You_cannot_sort_arrays_in_the_protocol ]
Sourcemodule Floatarray : sig ... end
OCaml

Innovation. Community. Security.