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.
Perl can't tell the difference between finite and infinite gather/take lists. (It literally can't--this is practically a perfect example of the halting problem.) So if you ask a gather/take for its length, the best thing Perl can do is to start gathering elements, hoping to eventually find an end.
Unfortunately, since "gather { take time }" is an infinite list, it's quite impossible for the gathering to ever finish, short of the universe coming to an end, the computer crashing, or a sysadmin killing the program. (Unless safe mode restricts the length of lazy lists, which I would recommend given the existence this little ball of hate.)
-- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker
Oceania has always been at war with Eastasia.