- array-map f array #!rest arraysprocedure
If array, (car arrays), ... all have the same domain and f is a procedure, then array-map returns a new immutable array with the same domain and getter
(lambda multi-index (apply f (map (lambda (g) (apply g multi-index)) (map array-getter (cons array arrays)))))
It is assumed that f is appropriately defined to be evaluated in this context.
It is expected that array-map and array-for-each will specialize the construction of
(lambda multi-index (apply f (map (lambda (g) (apply g multi-index)) (map array-getter (cons array arrays)))))
It is an error to call array-map if its arguments do not satisfy these conditions.
Note: The ease of constructing temporary arrays without allocating storage makes it trivial to imitate, e.g., Javascript's map with index. For example, we can add the index to each element of an array a by
(array-map + a (make-array (array-domain a) (lambda (i) i)))
or even
(make-array (array-domain a) (let ((a_ (array-getter a))) (lambda (i) (+ (a_ i) i))))