module Subarray:Functions for manipulating array subranges.sig
..end
i
and j
that define a
subregion within the array that ranges from element i
up to but not including element j
.val swap : 'a array -> int -> int -> unit
swap a i j
swaps the elements at positions i
and j
of a
.
0 <= i < Array.length a
0 <= j < Array.length a
val rev : 'a array -> int -> int -> unit
rev a i j
reverses the order of the elements in the range i
...j-1
.
0 <= i <= j <= Array.length a
val set_all : 'a array -> int -> int -> 'a -> unit
set_all a i j x
sets all the elements in the range i
...j-1
to x
.
0 <= i <= j <= Array.length a
val set_fun : 'a array -> int -> int -> (int -> 'a) -> unit
set_fun a i j f
sets each element k
in the range i
...j-1
to f k
.
0 <= i <= j <= Array.length a
val mem : 'a -> 'a array -> int -> int -> bool
mem x a i j
is true when there is a k
in the range
i
...j-1
such that x = a.(k)
.
0 <= i <= j <= Array.length a
val exists : ('a -> bool) -> 'a array -> int -> int -> bool
exists p a i j
is true when there is a k
in the range
i
...j-1
such that p a.(k)
.
0 <= i <= j <= Array.length a
val exists_const : ('a -> 'b -> bool) -> 'a -> 'b array -> int -> int -> bool
exists_const p x a i j
is the same as Subarray.exists
(p
x) a i j
, only faster because applying closures is slow.val for_all : ('a -> bool) -> 'a array -> int -> int -> bool
for_all p a i j
is true when for every k
in the range
i
...j-1
we have p a.(k)
.
0 <= i <= j <= Array.length a
val for_all_const : ('a -> 'b -> bool) -> 'a -> 'b array -> int -> int -> bool
for_all_const p x a i j
is the same as Subarray.for_all
(p
x) a i j
, only faster because applying closures is slow.val first : ('a -> bool) -> 'a array -> int -> int -> int
first p v
is the index of the first element of a
in the
range i
...j-1
satisfying p
, or j
if there is no such
k
.
0 <= i <= j <= Array.length a
val first_const : ('a -> 'b -> bool) -> 'a -> 'b array -> int -> int -> int
first_const p x a i j
is the same as Subarray.first
(p x)
a i j
, only faster because applying closures is slow.val fold_left : ('a -> 'b -> 'a) -> 'a -> 'b array -> int -> int -> 'a
fold_left f l a i j
computes
f (... (f (f l a.(i)) a.(i+1)) ...) a.(j-1)
.
0 <= i <= j <= Array.length a
val fold_right : ('a -> 'b -> 'b) -> 'a array -> int -> int -> 'b -> 'b
fold_right f a i j r
computes
f a.(i) (... (f a.(j-2) (f a.(j-1) r)) ...)
0 <= i <= j <= Array.length a
val foldi_left : ('a -> int -> 'b -> 'a) -> 'a -> 'b array -> int -> int -> 'a
fold_lefti f l a i j
computes
f (... (f (f l i a.(i)) (i+1) a.(i+1)) ...) (j-1) a.(j-1)
.
0 <= i <= j <= Array.length a
val foldi_right : (int -> 'a -> 'b -> 'b) -> 'a array -> int -> int -> 'b -> 'b
foldi_right f a i j r
computes
f i a.(i) (... (f (j-2) a.(j-2) (f (j-1) a.(j-1) r)) ...)
0 <= i <= j <= Array.length a
val fold_left_const : ('a -> 'b -> 'c -> 'b) -> 'a -> 'b -> 'c array -> int -> int -> 'b
fold_left_const f x l a i j
is Subarray.fold_left
(f x) l
a i j
, only faster since applying closures is slow.val fold_right_const : ('a -> 'b -> 'c -> 'c) -> 'a -> 'b array -> int -> int -> 'c -> 'c
fold_right_const f x a i j r
is Subarray.fold_right
(f x)
a i j r
, only faster since applying closures is slow.val foldi_left_const : ('a -> 'b -> int -> 'c -> 'b) -> 'a -> 'b -> 'c array -> int -> int -> 'b
fold_lefti f x l a i j
is Subarray.foldi_left
(f x) l a i
j
, only faster since applying closures is slow.val foldi_right_const : ('a -> int -> 'b -> 'c -> 'c) -> 'a -> 'b array -> int -> int -> 'c -> 'c
foldi_right_const f x a i j r
is Subarray.foldi_right
(f
x) a i j r
, only faster since applying closures is slow.val iter : ('a -> unit) -> 'a array -> int -> int -> unit
iter c a i j
evaluates c a.(k)
for each k
in the range
i
...j-1
.
0 <= i <= j <= Array.length a
val iteri : (int -> 'a -> unit) -> 'a array -> int -> int -> unit
iter c a i j
evaluates c k a.(k)
for each k
in the range
i
...j-1
.
0 <= i <= j <= Array.length a
val iter_const : ('a -> 'b -> unit) -> 'a -> 'b array -> int -> int -> unit
val iteri_const : ('a -> int -> 'b -> unit) -> 'a -> 'b array -> int -> int -> unit
val modify : ('a -> 'a) -> 'a array -> int -> int -> unit
modify f a i j
sets a.(k)
to f a.(k)
for each k
in the
range i
...j-1
.
0 <= i <= j <= Array.length a
val modify_const : ('a -> 'b -> 'b) -> 'a -> 'b array -> int -> int -> unit
modify_const f x a i j
is Subarray.modify
(f x) a i j
,
only faster because applying closures is slow.val sort : ('a -> 'a -> int) -> 'a array -> int -> int -> unit
sort c a i j
sorts elements of a in the range i
...j-1
in
ascending order as defined by the comparison function c. c x
y
returns a negative number if x comes before y, a positive
number if x comes after y and zero if x and y are order
equivalent.
0 <= i <= j <= Array.length a
val stable_sort : ('a -> 'a -> int) -> 'a array -> int -> int -> unit
stable_sort c a i j
sorts elements of a in the range
i
...j-1
in ascending order as defined by the comparison
function c. c x y
returns a negative number if x comes before
y, a positive number if x comes after y and zero if x and y are
order equivalent.
The sort is stable in that adjacent order equivalent elements remain in their original order.
0 <= i <= j <= Array.length a