Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re (tilly) 1: Mixing up da Arrays (Golf)

by tilly (Archbishop)
on Apr 18, 2001 at 19:39 UTC ( #73534=note: print w/ replies, xml ) Need Help??


in reply to Mixing up da Arrays (Golf)

Do I hear golf?

First at 48 chars, the one that modifies the original arguments like yours does:

sub Mix { my@a;@_=grep{@$_?push@a,shift@$_:0}@_ while@_;@a }
and a safe one that doesn't do that at 59 chars:
sub MixS { my@a;for(my$i;@_;++$i){@_=grep{$i<@$_&&push@a,$$_[$i]}@_}@a }


Comment on Re (tilly) 1: Mixing up da Arrays (Golf)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2014-12-26 06:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls