At 5:25 PM -0400 9/18/00, Robert Wingate wrote:
> > I'd like to build a non repeating random, something like, it
>> randomize the numbers but don't repeat them
>
>You can do this a few ways - generate the complete list & then randomize it,
>or check each element against the current contents before adding it. Here's
>a simple way:
>
>
>on buildNonRepeatingRandomList ofHowManyElements
> ls = []
> repeat while ls.count < ofHowManyElements
> rand = random( ofHowManyElements )
> if not( ls.getOne( rand )) then
> ls.add( rand )
> end if
> end repeat
>
> return ls
>end
>
Or, a little faster algorithm:
on buildNonRepeatingRandomList ofHowManyElements
ls = []
repeat with i = 1 to ofHowManyElements
add(ls, random(i), i)
end repeat
end
Irv
--
Lingo / Director / Shockwave development for all occasions
(We even do weddings and Bar Mitzvahs!)
See our kid's CD-Rom's at: http://www.furrypants.com
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]