1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Talk a bit out zero-rank and zero-size arrays.

This commit is contained in:
Marius Vollmer 2005-01-09 17:46:53 +00:00
parent bcbbea0e2f
commit 5e7b8a3d71

View file

@ -1635,18 +1635,29 @@ values. For example, arrays with an underlying @code{c64vector} might
be nice for digital signal processing, while arrays made from a be nice for digital signal processing, while arrays made from a
@code{u8vector} might be used to hold gray-scale images. @code{u8vector} might be used to hold gray-scale images.
The number of dimensions of an array is called its @dfn{rank}. Thus, a The number of dimensions of an array is called its @dfn{rank}. Thus,
matrix is an array of rank 2, while a vector has rank 1. When accessing a matrix is an array of rank 2, while a vector has rank 1. When
an array element, you have to specify one exact integer for each accessing an array element, you have to specify one exact integer for
dimension. These integers are called the @dfn{indices} of the element. each dimension. These integers are called the @dfn{indices} of the
An array specifies the allowed range of indices for each dimension via element. An array specifies the allowed range of indices for each
an inclusive lower and upper bound. These bounds can well be negative, dimension via an inclusive lower and upper bound. These bounds can
but the upper bound must be greater than or equal to the lower bound. well be negative, but the upper bound must be greater than or equal to
When all lower bounds of an array are zero, it is called a the lower bound minus one. When all lower bounds of an array are
@dfn{zero-origin} array. zero, it is called a @dfn{zero-origin} array.
For example, ordinary vectors are the special case of one dimensional, Arrays can be of rank 0, which could be interpreted as a scalar.
ordinary arrays and strings are one dimensional character arrays. Thus, a zero-rank array can store exactly one object and the list of
indices of this element is the empty list.
Arrays contain zero elements when one of their dimensions has a zero
length. These empty arrays maintain information about their shape: a
matrix with zero columns and 3 rows is different from a matrix with 3
columns and zero row, which again is different from a vector of zero
length.
Generalized vectors, such as strings, uniform numeric vectors, bit
vectors and ordinary vectors, are the special case of one dimensional
arrays.
@menu @menu
* Array Syntax:: * Array Syntax::
@ -1683,6 +1694,10 @@ decimal giving the lower bound of a dimension. There is one
@code{<@@lower>} for each dimension. When all lower bounds are zero, @code{<@@lower>} for each dimension. When all lower bounds are zero,
all @code{<@@lower>} parts are omitted. all @code{<@@lower>} parts are omitted.
As a special case, an array of rank 0 is printed as
@code{#0<vectag>(<scalar>)}, where @code{<scalar>} is result of
printing the single element of the array.
Thus, Thus,
@table @code @table @code
@ -1703,6 +1718,9 @@ is a uniform u8 array of rank 1.
@item #2u32@@2@@3((1 2) (2 3)) @item #2u32@@2@@3((1 2) (2 3))
is a uniform u8 array of rank 2 with index ranges 2..3 and 3..4. is a uniform u8 array of rank 2 with index ranges 2..3 and 3..4.
@item #0(12)
is a rank-zero array with contents 12.
@end table @end table
@node Array Procedures @node Array Procedures