"Ph. Marek" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Thursday 08 July 2004 05:25, Larry Wall wrote: > > : say @x[rand]; # how about now? > > > > Well, that's always going to ask for @x[0], which isn't a problem. > > However, if you say rand(@x), it has to calculate the number of > > elements in @x, which could take a little while... > I'd expect to be rand(@x) = rand(1)[EMAIL PROTECTED] = rand(1)*Inf = Inf or NaN.
I know it makes no difference in this particular case, but my personal preference would be to define rand(@x) as rand(@x) == @x.rand == @x[ rand int @x ] == @x[ rand(1) * @x ] guaranteeing a uniform distribution unless adverbial modifiers are used. Dave.