Go to the first, previous, next, last section, table of contents.


Uniform Array

Uniform Array 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.

prototype arguments in the following procedures are interpreted according to the table:

prototype       type                            printing character

#t              boolean (bit-vector)                    b
#\a             char (string)                           a
integer >0      unsigned integer                        u
integer <0      signed integer                          e
1.0             float (single precision)                s
1/3             double (double precision float)         i
+i              complex (double precision)              c
()              conventional vector

Unshared uniform character 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) strings.

(make-uniform-array #\a 3) => "$q2"

Unshared uniform boolean 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) section Bit Vectors.

(make-uniform-array #t 3) => #*000
==
#b(#f #f #f) => #*000
==
#1b(#f #f #f) => #*000

Other uniform vectors are written in a form similar to that of vectors, except that a single character from the above table is put between # and (. For example, '#e(3 5 9) returns a uniform vector of signed integers.

primitive: array? obj prototype
Returns #t if the obj is an array of type corresponding to prototype, and #f if not.

procedure: make-uniform-array prototype bound1 bound2 ...
Creates and returns a uniform array of type corresponding to prototype that has as many dimensions as there are bounds and fills it with prototype.

primitive: array-prototype array
Returns an object that would produce an array of the same type as array, if used as the prototype for make-uniform-array.

primitive: list->uniform-array rank prot lst
procedure: list->uniform-vector prot lst
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.

primitive: uniform-vector-fill! uve fill
Stores fill in every element of uve. The value returned is unspecified.

primitive: uniform-vector-length uve
Returns the number of elements in uve.

primitive: dimensions->uniform-array dims prototype [fill]
primitive: make-uniform-vector length prototype [fill]
Creates and returns a uniform array or vector of type corresponding to prototype with dimensions dims or length length. If the fill argument is supplied, the returned array is filled with this value.

primitive: uniform-array-read! ura [port-or-fdes] [start] [end]
primitive: uniform-vector-read! uve [port-or-fdes] [start] [end]
Attempts to read all elements of ura, in lexicographic order, as binary objects from port-or-fdes. 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.

The optional arguments start and end allow a specified region of a vector (or linearized array) to be read, leaving the remainder of the vector unchanged.

uniform-array-read! returns the number of objects read. port-or-fdes may be omitted, in which case it defaults to the value returned by (current-input-port).

primitive: uniform-array-write ura [port-or-fdes] [start] [end]
primitive: uniform-vector-write uve [port-or-fdes] [start] [end]
Writes all elements of ura as binary objects to port-or-fdes.

The optional arguments start and end allow a specified region of a vector (or linearized array) to be written.

The number of objects actually written is returned. port-or-fdes may be omitted, in which case it defaults to the value returned by (current-output-port).


Go to the first, previous, next, last section, table of contents.