Array Mapping
-------------
`(require 'array-for-each)'
- Function: array-map! array0 proc array1 ...
ARRAY1, ... must have the same number of dimensions as ARRAY0 and
have a range for each index which includes the range for the
corresponding index in ARRAY0. PROC is applied to each tuple of
elements of ARRAY1 ... and the result is stored as the
corresponding element in ARRAY0. The value returned is
unspecified. The order of application is unspecified.
- Function: array-for-each PROC ARRAY0 ...
PROC is applied to each tuple of elements of ARRAY0 ... in
row-major order. The value returned is unspecified.
- Function: array-indexes ARRAY
Returns an array of lists of indexes for ARRAY such that, if LI is
a list of indexes for which ARRAY is defined, (equal? LI (apply
array-ref (array-indexes ARRAY) LI)).
- Function: array-index-map! array proc
applies PROC to the indices of each element of ARRAY in turn,
storing the result in the corresponding element. The value
returned and the order of application are unspecified.
One can implement ARRAY-INDEXES as
(define (array-indexes array)
(let ((ra (apply make-array #f (array-shape array))))
(array-index-map! ra (lambda x x))
ra))
Another example:
(define (apl:index-generator n)
(let ((v (make-uniform-vector n 1)))
(array-index-map! v (lambda (i) i))
v))
- Function: array-copy! source destination
Copies every element from vector or array SOURCE to the
corresponding element of DESTINATION. DESTINATION must have the
same rank as SOURCE, and be at least as large in each dimension.
The order of copying is unspecified.