That pushes matters along a little further: you get the right behavior if the array is specialized. However, it's not clear to me why generalized arrays can't be reshaped, or why non-affine transforms expressed as reshapes require eager copying, rather than a lazy operation similar to mapping.
On Thu, Mar 16, 2023 at 3:29 PM Lucier, Bradley J < [email protected]> wrote: > > On Mar 16, 2023, at 2:32 PM, John Cowan <[email protected]> wrote: > > > > What''s the best way to transform an arbitrary array into a > 1-dimensional array in row-major order? > > > > You can access individual elements that way using the storage class > getter and setter, and you can use vector->array and array->vector, but the > result is not shared. Is there any alternative? > > If array is a specialized array and the elements are stored adjacently > (with either increasing or decreasing index in the body of the array) you > can > > (specialized-array-reshape array (make-interval (vector (interval-volume > (array-domain array))))) > > and the body of the new array is shared with the body of the old array. > > Is that what you mean? > > Brad
