in reply to Rosetta code: Split an array into chunks
I'd have thought the idiomatic Perl solution would splice:
sub chunky { my ($n, @strs) = @_; my $str = ''; $str .= join (' ', splice @strs, 0, $n) . "\n" while @strs; return length $str ? $str : "\n"; }
True laziness is hard work
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Rosetta code: Split an array into chunks
by LanX (Saint) on Oct 22, 2021 at 16:53 UTC | |
by LanX (Saint) on Oct 22, 2021 at 17:45 UTC | |
by tybalt89 (Monsignor) on Oct 22, 2021 at 17:57 UTC | |
by LanX (Saint) on Oct 22, 2021 at 18:01 UTC |
In Section
Meditations