for lines.rotor(3) -> ($,$,$third) { dd $third }

> On 23 Nov 2019, at 13:06, ToddAndMargo via perl6-users <perl6-us...@perl.org> 
> wrote:
> 
> On 2019-11-23 03:35, Elizabeth Mattijsen wrote:
>> If you don't want any results with less than 3 lines:
>>     for lines.rotor(3) -> @a {
>>        dd @a;
>>     }
>> If you *do* want results with 3 lines:
>>     for lines.rotor(3, :partial) -> @a {
>>         dd @a;
>>     }
>> Alternately as shown below:
>>     for lines -> $x, $y?, $z? {
>>         dd $x, $y, $z
>>     }
>> Note the question marks to make $y and $z optional: otherwise the last 
>> iteration will throw an exception if there were less than 3 lines left.
> 
> I only want to see every third line.
> 
> loop (my $I=0; $I < @Result.elems; $I+=3) { say "@Result[$I]";}
> 
> but with a "for" loop, not a "C" loop.

Reply via email to