Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: biased random number picking

by salva (Canon)
on Jul 12, 2012 at 05:32 UTC ( [id://981301]=note: print w/replies, xml ) Need Help??


in reply to Re: biased random number picking
in thread biased random number picking

the slice is expensive and not really required:
my $choice = int(rand($#options + 1)); say 'Choice #', $_, ' is ', $options[$choice]; $options[$choice] = $options[-1]; pop @options;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found