Node:Uniform Arrays, Next:Bit Vectors, Previous:Array Mapping, Up:Arrays
Uniform arrays have elements all of the same type and occupy less storage than conventional arrays. Uniform arrays with a single zero-based dimension are also known as uniform vectors. The procedures in this section can also be used on conventional arrays, vectors, bit-vectors and strings.
When creating a uniform array, the type of data to be stored
is indicated with a prototype argument. The following table
lists the types available and example prototypes:
prototype type printing character #t boolean (bit-vector) b #\a char (string) a #\nul byte (integer) y 's short (integer) h 1 unsigned long (integer) u -1 signed long (integer) e 'l signed long long (integer) l 1.0 float (single precision) s 1/3 double (double precision float) i 0+i complex (double precision) c () conventional vector
Unshared uniform arrays of characters with a single zero-based dimension
are identical to strings:
(make-uniform-array #\a 3) => "aaa"
Unshared uniform arrays of booleans with a single zero-based dimension
are identical to bit-vectors.
(make-uniform-array #t 3) => #*111
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
(. For example, a uniform vector of signed
long integers is displayed in the form
'#e(3 5 9).
|array? v [prot]||Scheme Procedure|
The prototype argument is used with uniform arrays and is described elsewhere.
|make-uniform-array prototype bound1 bound2 ...||Scheme Procedure|
|Create and return a uniform array of type corresponding to prototype that has as many dimensions as there are bounds and fill it with prototype.|
|array-prototype ra||Scheme Procedure|
|scm_array_prototype (ra)||C Function|
Return an object that would produce an array of the same type
as array, if used as the prototype for
|list->uniform-array ndim prot lst||Scheme Procedure|
|list->uniform-vector prot lst||Scheme Procedure|
|scm_list_to_uniform_array (ndim, prot, lst)||C Function|
|Return 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.|
|uniform-vector-fill! uve fill||Scheme Procedure|
|Store fill in every element of uve. The value returned is unspecified.|
|uniform-vector-length v||Scheme Procedure|
|scm_uniform_vector_length (v)||C Function|
|Return the number of elements in uve.|
|dimensions->uniform-array dims prot [fill]||Scheme Procedure|
|make-uniform-vector length prototype [fill]||Scheme Procedure|
|scm_dimensions_to_uniform_array (dims, prot, fill)||C Function|
|Create and return a uniform array or vector of type corresponding to prototype with dimensions dims or length length. If fill is supplied, it's used to fill the array, otherwise prototype is used.|
|uniform-array-read! ra [port_or_fd [start [end]]]||Scheme Procedure|
|uniform-vector-read! uve [port-or-fdes] [start] [end]||Scheme Procedure|
|scm_uniform_array_read_x (ra, port_or_fd, start, end)||C Function|
Attempt to read all elements of ura, in lexicographic order, as
binary objects from port-or-fdes.
If an end of file is encountered,
the objects up to that point are put into ura
(starting at the beginning) and the remainder of the array is
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-write v [port_or_fd [start [end]]]||Scheme Procedure|
|uniform-vector-write uve [port-or-fdes] [start] [end]||Scheme Procedure|
|scm_uniform_array_write (v, port_or_fd, start, end)||C Function|
Writes all elements of ura as binary objects to
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