Core.Option_array
SourceThis module extends Base.Option_array
with bin_io.
include Sexplib0.Sexpable.S1 with type 'a t := 'a t
include module type of struct include Base.Option_array end
with type 'a t := 'a t
include Base.Indexed_container.Generic
with type ('a, _, _) t := 'a t
and type 'a elt := 'a option
include Base.Container.Generic
with type ('a, _, _) t := 'a t
with type 'a elt := 'a option
val fold_result :
'a t ->
init:'acc ->
f:('acc -> 'a option -> ('acc, 'e) Base.Result.t) ->
('acc, 'e) Base.Result.t
val fold_until :
'a t ->
init:'acc ->
f:('acc -> 'a option -> ('acc, 'final) Base.Container.Continue_or_stop.t) ->
finish:('acc -> 'final) ->
'final
val sum :
(module Base.Container.Summable with type t = 'sum) ->
'a t ->
f:('a option -> 'sum) ->
'sum
These are all like their equivalents in Container
except that an index starting at 0 is added as the first argument to f
.
get t i
returns the element number i
of array t
, raising if i
is outside the range 0 to length t - 1
.
Similar to get
, but allocates result in the caller's stack region instead of heap.
These can cause arbitrary behavior when used for an out-of-bounds array access.
unsafe_get_some_exn t i
is unsafe because it does not bounds check i
. It does, however check whether the value at index i
is none or some, and raises if it is none.
unsafe_get_some_assuming_some t i
is unsafe both because it does not bounds check i
and because it does not check whether the value at index i
is none or some, assuming that it is some.
set t i x
modifies array t
in place, replacing element number i
with x
, raising if i
is outside the range 0 to length t - 1
.
map f [|a1; ...; an|]
applies function f
to a1
, a2
, ..., an
, in order, and builds the option_array [|f a1; ...; f an|]
with the results returned by f
.
map_some t ~f
is like map
, but None
elements always map to None
and Some
always map to Some
.
Unsafe versions of set*
. Can cause arbitrary behaviour when used for an out-of-bounds array access.
include Base.Blit.S1 with type 'a t := 'a t