Create a two-dimensional array at runtime
Line 1: The input parse doesn't care how you separate the dimensions as long as there are two distinct numbers.
Line 2: The list replication operator xx
will automatically thunkify its left side so this produces new subarrays for each replication.
Line 3: Subscripting with a closure automatically passes the size of the dimension to the closure, so we pick an appropriate random index on each level.
Line 4: Print each line of the array.
Typical run:
The most recent versions of Rakudo have preliminary support for 'shaped arrays'. Natively shaped arrays are a flexible feature for declaring typed, potentially multi-dimensional arrays, potentially with pre-defined dimensions. They will make memory-efficient matrix storage and matrix operations possible.
Typical run:
Last updated