- array-shape arrayprocedure
Returns the shape of a given array. The shape of an array is the default interval up to the maximum length of each dimension of the array or view. Unlike array-interval, the shape of an array always starts at the default (zero) index, and ends at the maximum dimension of the array.
In almost all instances, array-shape is the way one should get the full interval of indices in a given array. While array-interval provides the actual interval used to index into the storage-object of the array, array-shape is more useful when using most array APIs (e.g. array-ref); of which, these APIs will expect an array that is in the bounds of the shape rather than the interval, which is meant to be a tool for developers who are operating on the raw, underlying array structure directly.
(import generalized-arrays) (define a (make-array vector-storage-class #(3 3) 0)) (test "Shape of array a" (make-interval #(0 0) #(3 3)) (array-shape a)) (define b (array-slice a #(1 1) #(2 3))) (test "Interval of array b" (make-interval #(1 1) #(2 3)) (array-interval b)) (test "Shape of array b" (make-interval #(0 0) #(1 2)) (array-shape b))