According to the class Seq docs:
A Seq is born in a state where iterating it will consume the values.
...
...
A Seq can also be constructed with the sequence operator...or one of its variants. Assigning the values of a Seq to an array consumes a Seq that is not lazy.
Extending the example in the docs:
use v6.d;
my $s = (1...5);
say $s; # OUTPUT: «(1 2 3 4 5)»
say $s.^name; # OUTPUT: «Seq»
# My code:
say '-' x 10;
my @x = $s;
say @x;
say @x.^name;
say @x.elems;
say '-' x 10;
my @y = $s;
say @y;
say @y.^name;
say @y.elems;
--output:--
(1 2 3 4 5)
Seq
----------
[(1 2 3 4 5)]
Array
1
----------
[(1 2 3 4 5)]
Array
1
I expected the assignment:
my @x = $s;
to iterate over the Seq $s and consume $s during the assignment to @x. And, I expected there to be 5 elements in @x. But the output doesn't show that the Seq $s is being iterated over or consumed.
$s.is-lazy #False
The docs seem warn you that a Seq will get iterated over when you might not expect it, and then the Seq will be consumed and the next attempt to iterate over the Seq will cause errors. But, I seem to have the opposite problem: I can't make a Seq get consumed.
Only a partial answer (so far):
It looks like all your assignments above into an
@arraygo into the[0]th position of the array. Note how yourelemsabove equals1one.To assign each list element to each position of the array, you have to call
.liston it (pretty sure.Listand.Arraywill give you the same results), below:(Maybe the remainder of the answer, below):
Why don't your assignments of
$sabove consume theSeq? Possibly because Raku thinks you've only consumed them as one element and have not iterated through the elements of$sindividually.Really, really, guessing here, but if after assigning
$t.listto@zabove, if I try to call.say for $tI get the following error:HTH.