Re: code-block

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu