• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Random number generator without duplicates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Sending commands to the terminal with applescript
  • Next by Date: Here's a strange one
  • Previous by thread: Re: Random number generator without duplicates?
  • Next by thread: zapping gremlins
  • Index(es):
    • Date
    • Thread