Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: random number with range

by ikegami (Pope)
on Jun 01, 2006 at 18:06 UTC ( #553108=note: print w/ replies, xml ) Need Help??


in reply to Re^2: random number with range
in thread random number with range

Indeed, but the technique is particularly useful for sets. For example,

my @set = ( 1, 2, 3, 5, 8, 13, 21 ); my $random = $set[rand(@set)];
my @set = qw( apple orange banana cucumber ); my $random = $set[rand(@set)];


Comment on Re^3: random number with range
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2015-01-30 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My top resolution in 2015 is:

















    Results (248 votes), past polls