SRFI 231 - Easy conversion for common array formats Jens Axel Søgaard (13 Jan 2022 15:53 UTC)
Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier (13 Jan 2022 19:30 UTC)
Re: SRFI 231 - Easy conversion for common array formats Jens Axel Søgaard (13 Jan 2022 21:46 UTC)
Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier (16 Jan 2022 22:11 UTC)
Re: SRFI 231 - Easy conversion for common array formats John Cowan (17 Jan 2022 18:50 UTC)
Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier (18 Jan 2022 16:52 UTC)
Re: SRFI 231 - Easy conversion for common array formats John Cowan (19 Jan 2022 23:25 UTC)
Re: SRFI 231 - Easy conversion for common array formats Lucier, Bradley J (19 Jan 2022 23:45 UTC)
Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier (20 Jan 2022 15:54 UTC)
Re: SRFI 231 - Easy conversion for common array formats Jens Axel Søgaard (20 Jan 2022 16:19 UTC)
Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier (20 Jan 2022 17:57 UTC)
Re: SRFI 231 - Easy conversion for common array formats Jens Axel Søgaard (20 Jan 2022 19:08 UTC)

Re: SRFI 231 - Easy conversion for common array formats Bradley Lucier 18 Jan 2022 16:51 UTC

On 1/17/22 1:50 PM, John Cowan wrote:
> Lastly, it seems to be common to use a nested-vector representation when
> the problem domain has a fixed rank, as in a 2D or 3D transformation
> matrix, and there is no need to abstract over the interval.  Since there
> is no existing function to convert a nested vector to a nested list, it
> makes sense to me for `array` to accept either a list or a vector as its
> second argument.

I just looked at the (array unquoted-nested-vectors) form of Racket's
math/array library:

https://docs.racket-lang.org/math/array_construct.html

If you want to have vectors as elements of the array you quote the
vector elements, so it's an unambiguous representation.  The type of the
array is the most specific type that contains all the entries.

It's syntax, it can examine all the elements at compile time, so it
knows what the type of the array is.

There's list->array:

https://docs.racket-lang.org/math/array_convert.html

which is a procedure, like our list->array, which takes a list to an
array.  It takes an optional argument of dimensions to specify the shape.

And array->list, which takes an array and returns a flattened list.

There's also list*->array, which turns nested lists into an array.

And similar procedures for vectors.

So, what to do?

How about

(array nested-list-or-vector dimensions [storage-class [mutable? [safe?]]])

as a procedure.

Then Racket's

(array #[#[1 2 3] #[4 5 6]])

would become

(array '#[#[1 2 3] #[4 5 6]] 2)

In Racket

(array #['#[1 2 3] '#[4 5 6]])

builds a one-dimensional array with two vector elements, while this
proposal would be

(array '#[#[1 2 3] #[4 5 6]] 1)

Thoughts?

Brad