When I try to modify matrix in raku. I got the error :
my @matrix = ^100 .rotor(10);
@matrix[1;*] = 1 xx 10
Cannot modify an immutable Int (10)
in block <unit> at <unknown file> line 1
@matrix[1;1] = 3
Cannot modify an immutable List ((10 11 12 13 14 15 1...)
in block <unit> at <unknown file> line 1
Why all of those values are immutable value?
Well, lists are always immutable. You can modify their container, but not themselves. rotor
creates lists, so once they have been created, you can't modify them.
Don't know exactly what you want to do here, but looking at the errors here, I would say you need to turn those immutable lists into mutable Array
s:
my @matrix = ^100 .rotor(10).map: *.Array;
@matrix[1;*] = 1 xx 10;
@matrix[1;1] = 3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With