Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: Re^2: When the Best Solution Isn't

by japhy (Canon)
on Sep 23, 2002 at 14:12 UTC ( [id://200105]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re^2: When the Best Solution Isn't
in thread When the Best Solution Isn't

Don't fret -- an equally speedy solution is thus:
sub shuffle (\@) { my $d = shift; my @r = map rand, 0 .. $#$d; @$d[sort { $r[$a] <=> $r[$b] } 0 .. $#$d] = @$d; }
It requires you send it an actual array, of course, but it is just as fast.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Re: Re: Re^2: When the Best Solution Isn't
by diotalevi (Canon) on Sep 23, 2002 at 14:40 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 18:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found