Next: Bit Vectors, Previous: Conventional Arrays, Up: Arrays [Contents][Index]
Uniform Arrays and vectors are arrays whose elements are all of the same type. Uniform vectors occupy less storage than conventional vectors. Uniform Array procedures also work on vectors, uniform-vectors, bit-vectors, and strings.
SLIB now supports uniform arrys. The primary array creation procedure
is make-array
, detailed in See Arrays in SLIB.
Unshared uniform character 0-based arrays of rank 1 (dimension) are equivalent to (and can’t be distinguished from) strings.
(make-array "" 3) ⇒ "$q2"
Unshared uniform boolean 0-based arrays of rank 1 (dimension) are equivalent to (and can’t be distinguished from) bit-vectors.
(make-array '#1at() 3) ⇒ #*000 ≡ #1At(#f #f #f) ⇒ #*000
prototype arguments in the following procedures are interpreted according to the table:
prototype type display prefix () conventional vector #A +64i complex (double precision) #A:floC64b 64.0 double (double precision) #A:floR64b 32.0 float (single precision) #A:floR32b 32 unsigned integer (32-bit) #A:fixN32b -32 signed integer (32-bit) #A:fixZ32b -16 signed integer (16-bit) #A:fixZ16b #\a char (string) #A:char #t boolean (bit-vector) #A:bool
Other uniform vectors are written in a form similar to that of general
arrays, except that one or more modifying characters are put between the
#\A character and the contents list. For example, '#1A:fixZ32b(3 5 9)
returns a uniform vector of signed integers.
Returns #t
if the obj is an array of type corresponding to
prototype, and #f
if not.
Returns an object that would produce an array of the same type as
array, if used as the prototype for
list->uniform-array
.
Returns a uniform array of the type indicated by prototype prot with elements the same as those of lst. Elements must be of the appropriate type, no coercions are done.
In, for example, the case of a rank-2 array, lst must be a list of lists, all of the same length. The length of lst will be the first dimension of the result array, and the length of each element the second dimension.
If rank is zero, lst, which need not be a list, is the single element of the returned array.
Attempts to read all elements of ura, in lexicographic order, as binary objects from port. If an end of file is encountered during uniform-array-read! the objects up to that point only are put into ura (starting at the beginning) and the remainder of the array is unchanged.
uniform-array-read!
returns the number of objects read.
port may be omitted, in which case it defaults to the value
returned by (current-input-port)
.
Writes all elements of ura as binary objects to port. The
number of of objects actually written is returned. port may be
omitted, in which case it defaults to the value returned by
(current-output-port)
.
If an index is provided for each dimension of array returns
the index1, index2, …’th element of array. If
one more index is provided, then the last index specifies bit
position of the twos-complement representation of the array element
indexed by the other indexs returning #t
if the bit is 1,
and #f
if 0. It is an error if this element is not an exact
integer.
(logaref '#(#b1101 #b0010) 0) ⇒ #b1101 (logaref '#(#b1101 #b0010) 0 1) ⇒ #f (logaref '#2((#b1101 #b0010)) 0 0) ⇒ #b1101
If an index is provided for each dimension of array sets the
index1, index2, …’th element of array to
val. If one more index is provided, then the last index
specifies bit position of the twos-complement representation of an exact
integer array element, setting the bit to 1 if val is #t
and to 0 if val is #f
. In this case it is an error
if the array element is not an exact integer or if val is not
boolean.
Next: Bit Vectors, Previous: Conventional Arrays, Up: Arrays [Contents][Index]