Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: biased random number picking

by salva (Abbot)
on Jul 12, 2012 at 05:32 UTC ( #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;


Comment on Re^2: biased random number picking
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-05 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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









    Results (68 votes), past polls