Arrays read and write as a
# followed by the rank
(number of dimensions) followed by what appear as lists (of lists) of
elements. The lists must be nested to the depth of the rank. For each
depth, all lists must be the same length.
(make-array 'ho 3 3) => #2((ho ho ho) (ho ho ho) (ho ho ho))
Unshared conventional (not uniform) 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) vectors.
(make-array 'ho 3) => (ho ho ho)
When constructing an array, bound is either an inclusive range of indices expressed as a two element list, or an upper bound expressed as a single integer. So
(make-array 'foo 3 3) == (make-array 'foo '(0 2) '(0 2))
#tif the obj is an array, and
(index1, index2)element in array.
#tif its arguments would be acceptable to array-ref.
(index1, index2)element in array to new-value. The value returned by array-set! is unspecified.
make-shared-arraycan be used to create shared subarrays of other arrays. The mapper is a function that translates coordinates in the new array into coordinates in the old array. A mapper must be linear, and its range must stay within the bounds of the old array, but it can be otherwise arbitrary. A simple example:
(define fred (make-array #f 8 8)) (define freds-diagonal (make-shared-array fred (lambda (i) (list i i)) 8)) (array-set! freds-diagonal 'foo 3) (array-ref fred 3 3) => foo (define freds-center (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) (array-ref freds-center 0 0) => foo
The values of dim0, dim1, ... correspond to dimensions in the array to be returned, their positions in the argument list to dimensions of array. Several dims may have the same value, in which case the returned array will have smaller rank than array.
(transpose-array '#2((a b) (c d)) 1 0) => #2((a c) (b d)) (transpose-array '#2((a b) (c d)) 0 0) => #1(a d) (transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) => #2((a 4) (b 5) (c 6))
An enclosed array is not a general Scheme array. Its elements may not
be set using
array-set!. Two references to the same element of
an enclosed array will be
equal? but will not in general be
eq?. The value returned by array-prototype when given an
enclosed array is unspecified.
(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) => #<enclosed-array (#1(a d) #1(b e) #1(c f)) (#1(1 4) #1(2 5) #1(3 6))> (enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) => #<enclosed-array #2((a 1) (d 4)) #2((b 2) (e 5)) #2((c 3) (f 6))>
(array-shape (make-array 'foo '(-1 3) 5)) => ((-1 3) (0 4))
Array-dimensionsis similar to
array-shapebut replaces elements with a
0minimum with one greater than the maximum. So:
(array-dimensions (make-array 'foo '(-1 3) 5)) => ((-1 3) 5)
array-copy!but guaranteed to copy in row-major order.
#tiff all arguments are arrays with the same shape, the same type, and have corresponding elements which are either
array-equal?. This function differs from
equal?in that a one dimensional shared array may be array-equal? but not equal? to a vector or uniform vector.
array-contentsreturns that shared array, otherwise it returns
#f. All arrays made by make-array and make-uniform-array may be unrolled, some arrays made by make-shared-array may not be.
If the optional argument strict is provided, a shared array will be returned only if its elements are stored internally contiguous in memory.
Go to the first, previous, next, last section, table of contents.