Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Perl Monk, Perl Meditation
 
PerlMonks  

Re: list to LoL

by Maqs (Deacon)
on Jun 02, 2000 at 21:53 UTC ( #16077=note: print w/ replies, xml ) Need Help??


in reply to list to LoL

Below is Adam's modified version. It seemed to be working well

my @a = (1,2,3,4,5,6,7,8,9,10,11,12); my $n = 4; #parameter my @lol; while (@a){ @lol = (@lol, [splice @a, 0, $n]); $i=$i+$n; }; print "$lol[2][2]\n"; #for example


/Maqs.


Comment on Re: list to LoL
Download Code
RE: Re: list to LoL
by Adam (Vicar) on Jun 03, 2000 at 03:19 UTC
    I don't know why you are crediting me with that code, I didn't write it. I see no advantages to it except that it eliminates the need to call reverse(). It also has a useless $i (which $^W doesn't warn you about because you do it twice. Mine has that warning but its easily circumvented - after all you know it isn't a typo). Mine uses $i to avoid steping on the refs (note that @A is both the source and destination in my version). It still destroys @A because splice does that. The only way to preserve the original is make a back up copy.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-04-19 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls