--- Larry Wall <[EMAIL PROTECTED]> wrote:
The hard part being to pick a random number in [0,Inf) uniformly. :-)
Half of all numbers in [0, Inf) are in the range [Inf/2, Inf). Which collapses to the range [Inf, Inf). Returning Inf seems to satisfy the uniform distribution requirement: if you have a number you're waiting to see returned, just wait a bit longer...
I like the 1/n trick used in the Perl Cookbook (Picking a Random Line from a File). We could apply the same idea here:
rand($_)<1 && ($chosen=$_) for 1...Inf;
All right, it would take a bit longer for your program to run, but that's a performance issue for them to sort out on *-internals.
-David "sure Moore's Law will deal with it in a year or two" Green