Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by JavaFan (Canon)
on Sep 25, 2010 at 10:56 UTC ( #861947=note: print w/ replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

A solution that'll be hard to map to a different language (except perhaps Perl6):

sub TIESCALAR{bless[0,$_[1]],$_[0]} sub FETCH{${$_[0]}[0]++%${$_[0]}[1]?" ":"\n"}; sub chunk_array{tie local$",'main',shift;"@_\n";}


Comment on Re: Rosetta code: Split an array into chunks
Download Code
Replies are listed 'Best First'.
Re^2: Rosetta code: Split an array into chunks
by ahmad (Hermit) on Sep 25, 2010 at 18:06 UTC

    Looks good,

    Can you explain how it works?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (17)
As of 2015-07-28 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls