Shaped Arrays and Native Shaped Arrays already use one contiguous blob
to store all their data; in Shaped Arrays that's an array of pointers to
the stored objects, in a Native Shaped Array it'll be like a big array
of 32bit integers or whatever you have.
Regards
- Timo
On 05/02/2021 16:48, yary wrote:
This got me interested in
https://docs.raku.org/language/list#index-entry-Shaped_arrays
<https://docs.raku.org/language/list#index-entry-Shaped_arrays>
and I find myself wanting to implement a role "Shaped" and applying it
to List, for an immutable shaped list, whose implementation packs its
elements for o(1) lookup... on my ever-lengthening to-do list
-y
On Fri, Feb 5, 2021 at 10:06 AM Elizabeth Mattijsen <l...@dijkmat.nl
<mailto:l...@dijkmat.nl>> wrote:
> On 5 Feb 2021, at 15:49, Theo van den Heuvel
<vdheu...@heuvelhlt.nl <mailto:vdheu...@heuvelhlt.nl>> wrote:
> I cannot seem to find an idiomatic way to get the dimensions of
a multidimensional array,
> other than by looking at the size of the first row and column,
with @m[0;*].elems and @m[*;0].elems.
> Am I missing something in the docs?
If it's a shaped multidimensional array, you can call the .shape
method
my @a[3;3;3];
dd @a.shape; # (3,3,3)
If it is not, then your workaround appears the way to do it.