Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by karlgoethebier (Abbot)
on Oct 23, 2021 at 17:06 UTC ( #11137917=note: print w/replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

Stolen from brother BUK, our beloved former leader: print splice @a, 0, 5 for 1 .. 5; It rhymes somehow again! Not tested but I guess it works. I’m still on a mobile device and in a hurry.

See also Generate a # between 1 and 50 in groups of 5 as well as the sources of List::MoreUtils::PP:

sub natatime ($@) { my $n = shift; my @list = @_; return sub { return splice @list, 0, $n; } }

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137917]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-11-30 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?