Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize a fixed array to a value with Raku

Tags:

raku

It may be silly but I haven't found a good solution in the documentation about how to initialize a fixed array, or multidimensional array on an easy way without iterating.

my @array[10] = [0,0,0,0,0,0,0,0,0,0];
my @grid[100;100]; 
like image 585
Javi Avatar asked Dec 04 '19 11:12

Javi


1 Answers

I'd probably use the xx operator. Something like this :

my @array[10] = 0 xx 10;
my @grid[100;100] = [0 xx 100] xx 100;
like image 114
Scimon Proctor Avatar answered Nov 10 '22 01:11

Scimon Proctor