MONO_VECTOR
signatureThe MONO_VECTOR signature is a generic interface to monomorphic immutable sequences. The element type is required to be an equality type.
signature MONO_VECTOR
structure Word8Vector
: MONO_VECTOR
structure CharVector
: MONO_VECTOR
structure WideCharVector
: MONO_VECTOR
structure BoolVector
: MONO_VECTOR
structure IntVector
: MONO_VECTOR
structure RealVector
: MONO_VECTOR
structure Int{N}Vector
: MONO_VECTOR
structure Real{N}Vector
: MONO_VECTOR
eqtype vector
eqtype elem
val maxLen : int
val fromList : elem list -> vector
val tabulate : (int * (int -> elem)) -> vector
val length : vector -> int
val sub : (vector * int) -> elem
val extract : (vector * int * int option) -> vector
val concat : vector list -> vector
val mapi : ((int * elem) -> elem) -> (vector * int * int option) -> vector
val map : (elem -> elem) -> vector -> vector
val appi : ((int * elem) -> unit) -> (vector * int * int option) -> unit
val app : (elem -> unit) -> vector -> unit
val foldli : ((int * elem * 'a) -> 'a) -> 'a -> (vector * int * int option) -> 'a
val foldri : ((int * elem * 'a) -> 'a) -> 'a -> (vector * int * int option) -> 'a
val foldl : ((elem * 'a) -> 'a) -> 'a -> vector -> 'a
val foldr : ((elem * 'a) -> 'a) -> 'a -> vector -> 'a
eqtype vector
eqtype elem
maxLen
fromList l
tabulate (n, f)
fromList (List.tabulate (n, f))If n < 0 or
maxLen
< n, then the Size exception is raised.
length vec
sub (vec, i)
extract slice
concat l
mapi f slice
map f vec
mapi f slice
is equivalent to:
fromList (List.map f (foldri (fn (i,a,l) => (i,a)::l) [] slice))
The function map applies f to the whole vector and does not supply the element index to f. Thus the expression map f vec
is equivalent to:
mapi (f o #2) (vec, 0, NONE)
appi f slice
app f vec
The function app
applies f to the whole vector and does not supply the element index to f. Thus the expression app f vec
is equivalent to:
appi (f o #2) (vec, 0, NONE)
foldli f init slice
foldri f init slice
foldl f init vec
foldr f init vec
The functions foldl and foldr work on the whole vector vec and do not supply the element index to f. Thus the expression foldl f init vec
is equivalent to:
foldli (fn (_, a, x) => f(a, x)) init (vec, 0, NONE)
Example:
One can extract the list of elements in a vector vec by the expression:
foldr (op ::) [] vec
The type String.string is identical to CharVector.vector.
MONO_ARRAY, Vector
Last Modified January 21, 1997
Copyright © 1996 AT&T