Re: Random number generator without duplicates?
Re: Random number generator without duplicates?
- Subject: Re: Random number generator without duplicates?
- From: Daniel Robinson <email@hidden>
- Date: Thu, 19 Apr 2001 20:55:27 -0400
Here's my solution:
Just replace the selected item with the last item and decrement the counter.
N items, N passes.
Regards,
--Dan
------------------------------------------------------------------------
set TheList to {"Albert", "Betty", "Charles", "Daniel", "Egdar", "Francis",
"George", "Hannah", "Irving", "Jill", "Kelly", "Lucy", "Mike", "Nancy", "Oscar",
"Phyllis", "Quincy", "Rachel", "Steve", "Tess", "Uncle", "Vicky", "Walter",
"Xenobia", "Yolanda", "Zeke"} as list
set N to the count of items in TheList
repeat while N > 0
random number N - 1 -- (I get it back on the next line)
set ThisNumber to the result + 1 -- (Don't want a zero)
display dialog "This name is " & item ThisNumber of TheList <opt-L>
& return & "Press Return to Continue"
set item ThisNumber of TheList to item N of TheList
set N to N - 1
end repeat