On Sat, 23 Nov 2019 at 07:00, ToddAndMargo via perl6-users
<perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
Hi All,
In a "for" loop, what is the syntax for "by 3"?
for @x.lines by 3
In other words, every third line.
Many thanks,
-T
On 2019-11-23 03:30, Raymond Dresens wrote:
Hello,
This seems possible:
> my @x = (1, 2, 3, 4, 8, 16, 32, 64, 128);
[1 2 3 4 8 16 32 64 128]
Then:
> for @x -> $x, $y, $z { $x.say }
1
4
32
And:
> for @x -> $x, Any, Any { $x.say }
1
4
32
...assigning to 'Any' seems to 'just work'. Assigning to 'Nil' didn't
work, however.
Is this what you are looking for?
Perhaps there's a better way for doing this? If so, I'd like to know too :)
Regards,
Raymond.
Hi Raymond,
Sweet. And I have access to the other lines if I want.
$ p6 ' my @x=<a b c D E F h i j>; for @x -> $L1, $L2, $L3 { say "L1 =
$L1\nL2 = $L2\nL3 = $L3\n" };'
L1 = a
L2 = b
L3 = c
L1 = D
L2 = E
L3 = F
L1 = h
L2 = i
L3 = j
Thank you!
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~