Inline: > ---------- Forwarded message --------- > From: Simon Proctor <simon.proc...@gmail.com> > Date: Sat, Nov 23, 2019 at 3:34 AM > Subject: Re: for by 3? > To: ToddAndMargo <toddandma...@zoho.com> > Cc: perl6-users <perl6-us...@perl.org> > > If you want to read you lines in groups of 3 then you want batch : > for @x.lines.batch(3) -> @b > If you just want the third line and throw away the first I'd probably do a > tail on that. > for @x.lines.batch(3).map( *.tail ) -> $l > Note you need to map the tail on each batch of three not slap it on the > end.
Hi Simon, can you explain to me what the "->" arrow is doing in your above? All I see in the docs is "->" used within the signature part of a sub. I can get some "->" arrow-containing code to work (below), but it doesn't resemble your code. Specifically, if I drop the block containing 'put', Raku/Perl6 throws an error. Any advice appreciated, Bill. mbook:~ homedir$ cat testcode5.p6 first line of code second line of code third line of code fourth line of code fifth line of code mbook:~ homedir$ cat testcode5.p6 | perl6 -e 'my @b; for lines.batch(3) -> @b {put @b};' first line of code second line of code third line of code fourth line of code fifth line of code mbook:~ homedir$ cat testcode5.p6 | perl6 -e 'my @b; for lines.rotor(3) -> @b {put @b};' first line of code second line of code third line of code mbook:~ homedir$ cat testcode5.p6 | perl6 -e 'my $b; for lines.batch(3) -> $b {put $b};' first line of code second line of code third line of code fourth line of code fifth line of code mbook:~ homedir$ cat testcode5.p6 | perl6 -e 'my $b; for lines.batch(3) -> $b;' ===SORRY!=== Error while compiling -e Malformed parameter at -e:1 ------> my $b; for lines.batch(3) -> $b;⏏<EOL> mbook:~ homedir$