Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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; }

Comment on Re: Mixing up da Arrays (Golf)
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-06 04:08 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (70 votes), past polls