Re: Common Lisp `row-major-aref`
Per Bothner 02 Sep 2023 15:35 UTC
On 9/1/23 23:08, John Cowan wrote:
> In CL the function row-major-aref accepts an array and a single index *n* and returns the *n*th element of the array in row-major order. There is a corresponding function (setf row-major-aref) serving as the corresponding mutator. This is equivalent to:
>
> (define (row-major-aref array n)
> (vector-ref (array->vector array) n))
>
> but does not reify the results of `array->vector`. Is there some way to do this with SRFI 231?
In srfi-164 array->vector returns a view, not a copy.
So your define works, and the same approach works for setting.
It is unfortunate that array->vector is incompatible between srfi-231 and srfi-164.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/