chickadee » srfi-179 » array-translate

array-translate array translationprocedure

Assumes that array is a valid array, translation is a valid translation, and that the dimensions of the array and the translation are the same. The resulting array will have domain (interval-translate (array-domain array) translation).

If array is a specialized array, returns a new specialized array

(specialized-array-share
 array
 (interval-translate (array-domain array)
                     translation)
 (lambda multi-index
   (apply values
          (map -
               multi-index
               (vector->list translation)))))

that shares the body of array, as well as inheriting its safety and mutability.

If array is not a specialized array but is a mutable array, returns a new mutable array

(make-array
 (interval-translate (array-domain array)
                     translation)
 (lambda multi-index
   (apply (array-getter array)
          (map -
               multi-index
               (vector->list translation))))
 (lambda (val . multi-index)
   (apply (array-setter array)
          val
          (map -
               multi-index
               (vector->list translation)))))
 

that employs the same getter and setter as the original array argument.

If array is not a mutable array, returns a new array

(make-array
 (interval-translate (array-domain array)
                     translation)
 (lambda multi-index
   (apply (array-getter array)
          (map - multi-index (vector->list translation)))))

that employs the same getter as the original array.

It is an error if the arguments do not satisfy these conditions.