Re: code-block
- Posted by jiri <j.babor at GNS.CRI.NZ> Sep 10, 2000
- 377 views
On Sun, 10 Sep 2000 11:43:14 -0700, Michael Nelson <MichaelANelson at WORLDNET.ATT.NET> wrote: >Matt Lewis wrote: > >> function rand_not( integer x ) >> integer r >> r = rand( max-1 ) >> if r >= x then r += 1 end if >> return r >> end function >> > Why didn't I think of that--excellent fast code. > >-- Mike Nelson I agree, very clever. On a similar note: function anything_but(integer min, integer max, integer excluded) integer r r = rand(max-min) + min - 1 if r = excluded then return max end if return r end function jiri