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

Re: Weighted random numbers generator

by demerphq (Chancellor)
on Mar 13, 2003 at 23:09 UTC ( [id://242883]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!perl -l
    my %weights=(a=>1,b=>2,c=>3);
    ...
        $_->[0]<=$r and $r<$_->[1] and print $_->[-1]
            foreach @values;
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-29 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found