item random() (was Random(3) often returns 1)
Geoff Canyon
geoffc at inspiredlogic.com
Thu Jun 8 19:35:49 EDT 2006
I just ran this code
on mouseUp
repeat 1000
add 1 to x[random(3)]
end repeat
put sum(x) into y
combine x using cr and tab
put x & cr & cr & y
end mouseUp
and got this:
1 329
2 328
3 328
985
Note that the three numbers don't add up to 1000, but there are no
other numbers. ???
Running it again I get:
1 339
2 335
3 338
1012
_More_ than 1000? What the???
Even stranger, making this slight adjustment fixes it:
on mouseUp
repeat 1000
put random(3) into z
add 1 to x[z]
end repeat
put sum(x) into y
combine x using cr and tab
put x & cr & cr & y
end mouseUp
Anyone know what I'm not seeing?
regards,
Geoff
More information about the use-livecode
mailing list