Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by karlgoethebier (Abbot)
on Oct 23, 2021 at 17:06 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-25 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found