chickadee » slib-arraymap » array-index-map!

array-index-map! ARR PROCprocedure

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 '#() (array-dimensions array))))
    (array-index-map! ra (lambda x x))
    ra))

Another example:

(define (apl:index-generator n)
  (let ((v (make-vector n 1)))
    (array-index-map! v (lambda (i) i))
    v))