package octez-l2-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-l2-libs.wasmer/Tezos_wasmer/Memory/Array/index.html
Module Memory.Array
Source
Operations on C arrays.
get a n
returns the n
th element of the zero-indexed array a
. The semantics for non-scalar types are non-copying, as for (!@)
.
If you rebind the CArray
module to Array
then you can also use the syntax a.(n)
instead of Array.get a n
.
Raise Invalid_argument "index out of bounds"
if n
is outside of the range 0
to (CArray.length a - 1)
.
set a n v
overwrites the n
th element of the zero-indexed array a
with v
.
If you rebind the CArray
module to Array
then you can also use the a.(n) <- v
syntax instead of Array.set a n v
.
Raise Invalid_argument "index out of bounds"
if n
is outside of the range 0
to (CArray.length a - 1)
.
unsafe_get a n
behaves like get a n
except that the check that n
between 0
and (CArray.length a - 1)
is not performed.
unsafe_set a n v
behaves like set a n v
except that the check that n
between 0
and (CArray.length a - 1)
is not performed.
of_string s
builds an array of the same length as s
plus one, and writes the elements of s
to the corresponding elements of the array with the null character '\0' as a last element.
of_list t l
builds an array of type t
of the same length as l
, and writes the elements of l
to the corresponding elements of the array.
to_list a
builds a list of the same length as a
such that each element of the list is the result of reading the corresponding element of a
.
iter f a
is analogous to Array.iter f a
: it applies f
in turn to all the elements of a
.
iter f a
is analogous to Array.iteri f a
: it applies f
in turn to all the elements of a
but the function is applied to the index of the element as first argument, and the element itself as second argument
map t f a
is analogous to Array.map f a
: it creates a new array with element type t
whose elements are obtained by applying f
to the elements of a
.
mapi
behaves like Array.mapi
, except that it also passes the index of each element as the first argument to f
and the element itself as the second argument.
CArray.fold_left (@) x a
computes (((x @ a.(0)) @ a.(1)) ...) @ a.(n-1)
where n
is the length of the array a
.
CArray.fold_right f a x
computes a.(0) @ (a.(1) @ ( ... (a.(n-1) @ x) ...))
where n
is the length of the array a
.
Return the address of the first element of the given array.
from_ptr p n
creates an n
-length array reference to the memory at address p
.
make t n
creates an n
-length array of type t
. If the optional argument ?initial
is supplied, it indicates a value that should be used to initialise every element of the array. The argument ?finalise
, if present, will be called just before the memory is freed.
sub a ~pos ~length
creates a fresh array of length length
containing the elements a.(pos)
to a.(pos + length - 1)
of a
.
Raise Invalid_argument "CArray.sub"
if pos
and length
do not designate a valid subarray of a
.
Retrieve the element type of an array.