chickadee » generalized-arrays » array-reshape

array-reshape array dimensionprocedure

Reshapes the array to the default interval constructed by the provided dimension. This is done by performing a full copy of the array (as opposed to creating an array view). An error is signaled if the new shape does not have the same length as the existing shape.

 
(import generalized-arrays
        test)

(define a
  (make-array-from-storage vector-storage-class
                           #(4)
                           (vector 1 2 3 4)))

(test-assert "Reshaping array to a 2x2"
  (array=? (array-reshape a #(2 2))
           (make-array-from-storage vector-storage-class
                                    #(2 2)
                                    (vector 1 2
                                            3 4))))

(test-assert "Array-reshape never makes an array view"
  (not (array-view? (array-reshape a #(2 2)))))