Re: SRFI 231 - Easy conversion for common array formats
Bradley Lucier 16 Jan 2022 22:11 UTC
On 1/13/22 4:46 PM, Jens Axel Søgaard wrote:
> 3. An array with a generic storage class can store lists or vectors or
> other arrays as its entries, so without specifying a domain
> interval, or
> at the very least a domain dimension, the examples you give are
> ambiguous. I suppose if arrays hold only numbers, then it is
> unambiguous.
>
>
> I must admit I didn't think of that.
I made some changes to
https://github.com/gambiteer/srfi-231/tree/specialized-from-data
that did not include code to implement this suggestion.
I suppose one could do something like
(define (fast-array nested-list interval)
(list->array (flatten nested-list) interval))
but I don't see how to get around specifying the domain interval.
Or perhaps
(define (nested-list-of-numbers->array nested-list)
(if (right-shape nested-list)
(list->array (flatten nested-list) (nested-list->interval
nested-list))))
where nested-list->interval does the obvious thing, but I'm not sure
that this should be in the library.
Brad