Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Rosetta code: Split an array into chunks

by paddy3118 (Acolyte)
on Sep 26, 2010 at 18:09 UTC ( #862103=note: print w/ replies, xml ) Need Help??


in reply to Rosetta code: Split an array into chunks

Another Python solution:

>>> def formatter(data, chunksize=3): return ''.join( (' ' if i % chunksize else '\n') + d for i, d in enumerate(data))[1:] >>> print formatter(("a", "bb", "c", "d", "e", "f", "g", "h"), 3) a bb c d e f g h


Comment on Re: Rosetta code: Split an array into chunks
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://862103]
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: (14)
As of 2015-07-03 08:18 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 (49 votes), past polls