Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to return a list using recursion?

by BrowserUk (Pope)
on Aug 07, 2012 at 04:53 UTC ( #985879=note: print w/ replies, xml ) Need Help??


in reply to How to return a list using recursion?

sub chunks{ my( $n, @in ) = @_; join ",\n", map join(' ', splice @in, 0, $n), 0 .. $#in / $n; };; print chunks( 3, 'a'..'z' );; a b c, d e f, g h i, j k l, m n o, p q r, s t u, v w x, y z print chunks( 10, 'a'..'z' );; a b c d e f g h i j, k l m n o p q r s t, u v w x y z print chunks( 26, 'a'..'z' );; a b c d e f g h i j k l m n o p q r s t u v w x y z print chunks( 13, 'a'..'z' );; a b c d e f g h i j k l m, n o p q r s t u v w x y z print chunks( 6, 'a'..'z' );; a b c d e f, g h i j k l, m n o p q r, s t u v w x, y z

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


Comment on Re: How to return a list using recursion?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (13)
As of 2014-10-23 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls