package tezos-protocol-environment
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=7062cd57addd452852598a2214ade393130efa087b99068d53713bdf912b3680
sha512=08e4091144a03ce3c107fb91a66501bd8b65ca3278917c455a2eaac6df3e108ade63f6ab8340a4bb152d60f404326e464d0ec95d26cafe8e82f870465d24a5fc
doc/tezos-protocol-environment.structs/Tezos_protocol_environment_structs/V9/Array/index.html
Module V9.ArraySource
include module type of struct include Array end
An alias for the type of arrays.
Return the length (number of elements) of the given 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.
append v1 v2 returns a fresh array containing the concatenation of the arrays v1 and v2.
copy a returns a copy of a, that is, a fresh array containing the same elements as a.
to_list a returns the list of all the elements of a.
of_list l returns a fresh array containing the elements of l.
Iterators
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); ().
Same as iter, but the function is applied to the index of the element as first argument, and the element itself as second argument.
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) |].
Same as map, but the function is applied to the index of the element as first argument, and the element itself as second argument.
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.
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
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).
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).
Same as for_all, but for a two-argument predicate.
Same as exists, but for a two-argument predicate.
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).
Same as mem, but uses physical equality instead of structural equality to compare list elements.
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.
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.
Arrays of pairs
split [|(a1,b1); ...; (an,bn)|] is ([|a1; ...; an|], [|b1; ...; bn|]).