Previous: Bit Vectors, Up: Arrays


5.4.4 Array Mapping

(require 'array-for-each) SCM has some extra functions in feature array-for-each:

— Function: array-fill! array fill

Stores fill in every element of array. The value returned is unspecified.

— Function: serial-array:copy! destination source

Same as array:copy! but guaranteed to copy in row-major order.

— Function: array-equal? array0 array1 ...

Returns #t iff all arguments are arrays with the same shape, the same type, and have corresponding elements which are either equal? or 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.

— Function: array-map! array0 proc array1 ...

If array1, ... are arrays, they 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. If they are scalars, that is, not arrays, vectors, or strings, then they will be converted internally to arrays of the appropriate shape. 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.

Handling non-array arguments is a SCM extension of array-map!

— Function: serial-array-map! array0 proc array1 ...

Same as array-map!, but guaranteed to apply proc in row-major order.

— Function: array-map prototype proc array1 array2 ...

array2, ... must have the same number of dimensions as array1 and have a range for each index which includes the range for the corresponding index in array1. proc is applied to each tuple of elements of array1, array2, ... and the result is stored as the corresponding element in a new array of type prototype. The new array is returned. The order of application is unspecified.

— Function: scalar->array scalar array prototype
— Function: scalar->array scalar array

Returns a uniform array of the same shape as array, having only one shared element, which is eqv? to scalar. If the optional argument prototype is supplied it will be used as the prototype for the returned array. Otherwise the returned array will be of the same type as array if that is possible, and a conventional array if it is not. This function is used internally by array-map! and friends to handle scalar arguments.