Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Mixing up da Arrays (Golf)

by kschwab (Priest)
on Apr 18, 2001 at 18:24 UTC ( #73505=note: print w/replies, xml ) Need Help??


in reply to Mixing up da Arrays (Golf)

I have no idea if this is quicker or more efficient, but it's uglier:)

#!/usr/bin/perl -w use strict; sub Mix; my @Row1=(1,3,5,7); my @Row2=(2,4,6); my @Row3=(9,9,9); my @Row4=Mix(\@Row1,\@Row2,\@Row3); print "@Row4\n"; sub Mix { my @Result; for (0..scalar @{(sort {$#{$b} <=> $#{$a}} @_)[0]}) { foreach my $a (@_) { push(@Result,@$a[$_]) if ($_ <= $#{$a}); } } @Result; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2016-09-26 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (492 votes). Check out past polls.