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

Re: Mixing up da Arrays (Golf)

by kschwab (Vicar)
on Apr 18, 2001 at 18:24 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://73505]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-19 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found