Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: How to return a list using recursion?

by ig (Vicar)
on Aug 07, 2012 at 06:11 UTC ( #985889=note: print w/replies, xml ) Need Help??


in reply to How to return a list using recursion?

what goes here?
sub _array_chunk5 { my @arr = @_; # Base case == when @arr is <= 5 return ( join( " ", @arr ) ) unless @arr > 5; # what goes here ? return ( join( " ", splice ( @arr, 0, 5 ) ) , _array_chunk5(@arr) + ); }

But I might write it more like:

sub _array_chunk5x { my @arr = @_; return ( ) if(@arr == 0); return ( join( " ", splice( @arr, 0, 5 ) ), _array_chunk5(@arr) ); }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985889]
help
Chatterbox?
[thepkd]: Hi, in trying to create an Array of Hash of Array of Hash. You read it right. Is it possible to dereference it without using temps?
[GotToBTru]: what are temps?
[GotToBTru]: you can always have ${${${$array[0]}{ key1}}[1]}{key2}
[GotToBTru]: I think I have that inside out .. but you get the point
[choroba]: $array[0]{key1}[1] {key2}
[thepkd]: ??

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2016-12-06 13:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.