Lexicographical access to arrays John Cowan (09 Apr 2026 18:59 UTC)
Re: Lexicographical access to arrays Per Bothner (09 Apr 2026 19:47 UTC)
Re: Lexicographical access to arrays Alex Shinn (09 Apr 2026 23:48 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 00:22 UTC)
Re: Lexicographical access to arrays Per Bothner (10 Apr 2026 01:48 UTC)
Re: Lexicographical access to arrays John Cowan (10 Apr 2026 05:52 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 15:33 UTC)
Re: Lexicographical access to arrays Bradley Lucier (10 Apr 2026 15:36 UTC)
Re: Lexicographical access to arrays Bradley Lucier (11 Apr 2026 00:32 UTC)
Re: Lexicographical access to arrays John Cowan (11 Apr 2026 04:03 UTC)
Re: Lexicographical access to arrays Bradley Lucier (11 Apr 2026 17:37 UTC)

Re: Lexicographical access to arrays Per Bothner 09 Apr 2026 19:46 UTC


On 4/9/26 11:59, John Cowan wrote:
> Common Lisp has an accessor (array-major-aref a n) which retrieves the
> nth element of an array enumerated in lexicographical order.  As such,
> it also comes with a setter:  (setf (array-major-aref a n) x) where x
> is the new value.  Setf is equivalent to SRFI 17's version of `set!`,
> and replaces essentially all mutator functions in CL (rplaca and
> rplacd are still there for hysterical raisins).
>
> It seems partly possible to emulate this using array-body and
> array-indexer, but then you have to know what kind of body you have
> (vector, @vector, or something else).  I think it would be worth
> adding these.  (Maybe there's a way to do them already, in which case
> it would be worth pointing it out in 231bis.)

SRFI-164 have array-flatten and array->vector:

     Return a vector consisting of the elements of the array in row-major-order.

     The result of array-flatten is a fresh (mutable and simple) copy, not a view.
     The result of array->vector is a view: If array is mutable, then modifying
     array changes the flattened result and vice versa.

     If array is 'simple', array->vector returns the 'underlying vector;.
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/'