Anomalies

Dar Scott dsc at swcp.com
Fri Jul 11 11:54:01 EDT 2003


I got to thinking Shari that you might be wanting a different function, 
anyway.

Consider this:
random(5) returns one of 1, 2, 3, 4, 5
random(4) returns one of 1, 2, 3, 4
random(3) returns one of 1, 2, 3
random(2) returns one of 1, 2
random(1) returns one of 1

And adding the one you want,

random(0) returns one of 0

That looks like an anomaly to me.

Maybe, you want this:

random0up(5) returns one of 0, 1, 2, 3, 4, 5
random0up(4) returns one of 0, 1, 2, 3, 4
random0up(3) returns one of 0, 1, 2, 3
random0up(2) returns one of 0, 1, 2
random0up(1) returns one of 0, 1
random0up(0) returns one of 0

In that case, 0 fits right in.

You can use this function, if this is the behavior you want:

function random0up n
   return random(n+1)-1
end random0up

I hope this helps.

Dar Scott




More information about the metacard mailing list