David A. Black wrote: > Hi -- > > On Sun, 7 Mar 2004, Joel VanderWerf wrote: > > >>Hal Fulton wrote: >> >>>Someone suggested allowing not just rand(Fixnum) and rand(Range) >>>but in general rand(Enumerable). >> >>Would be tricky for general Enumerables... >> >> class Seq >> include Enumerable >> def each >> i = 0 >> loop do >> yield i >> i += 1 >> end >> end >> end > > > I'm not quite following (?) -- I think the original idea was > something like: > > module Enumerable > def rand > to_a[Kernel.rand(size)] > end > end Wouldn't size be infinite in this case? Now, if you wanted a non-uniform random distribution, it would be possible. But how do you uniformly choose from an infinite set?