signature MLTON_VECTOR =
sig
val create: int -> {done: unit -> 'a vector,
sub: int -> 'a,
update: int * 'a -> unit}
val unfoldi: int * 'b * (int * 'b -> 'a * 'b) -> 'a vector * 'b
end
-
create ninitiates the construction a vector v of length
n, returning functions to manipulate the vector. Thedonefunction may be called to return the created vector; it is an error to calldonebefore all entries have been initialized; it is an error to calldoneafter having calleddone. Thesubfunction may be called to return an initialized vector entry; it is not an error to callsubafter having calleddone. Theupdatefunction may be called to initialize a vector entry; it is an error to callupdateafter having calleddone. One must initialize vector entries in order from lowest to highest; that is, before callingupdate (i, x), one must have already calledupdate (j, x)for alljin[0, i). Thedone,sub, andupdatefunctions are all constant-time operations. -
unfoldi (n, b, f)constructs a vector v of length
n, whose elements vi are determined by the equations b0 = b and (vi, bi+1) = f (i, bi).