Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://73505]
[choroba]: Corion A colleague has helped me. It seems the "Modification of read-only value" was caused by old Test::More version which doesn't have done_testing, plus the old bug with $@ sometimes showing a different exception
[choroba]: will upload a fixed version and see
[Corion]: choroba: Ah, OK - sounds like a really weird combination :)

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2018-06-25 14:12 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.