chickadee » generalized-arrays » array-tabulate

array-tabulate storage-class dimension procprocedure

Constructs an array by allocating a storage-object of the provided storage-class with the provided dimension(s) as make-array does. Unlike make-array which fills the array with a single value, array-tabulate sets the value at each index by calling (proc index) for every index in the array.

 
(import generalized-arrays
        test)

(test "Constructed array contains all of its indices."
      #a2v((#(0 0) #(0 1) #(0 2))
           (#(1 0) #(1 1) #(1 2))
           (#(2 0) #(2 1) #(2 2)))
      (array-tabulate vector-storage-class
                      #(3 3)
                      (lambda (idx) idx)))