• 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: Paul Berkowitz <email@hidden>
  • Date: Tue, 17 Apr 2001 09:33:43 -0700

On 4/17/01 6:54 AM, "email@hidden" <email@hidden> wrote:

> How can I get a list of random numbers that does not include any duplicates?
> I would want to use these parameters: six random numbers from 1 to 56, as a
> list or as six variables, no duplicate numbers.


property numberList : {1}

if numberList = {1} then -- only do this once
repeat 55 times
set x to last item of numberList
set end of numberList to (x + 1)
end repeat
end if

set randomList to {}
repeat 6 times
set check to false
repeat until check is true
set y to some item of numberList
if {y} is not in randomList then
set end of randomList to y
set check to true
end if
end repeat
end repeat
randomList


--
Paul Berkowitz


References: 
 >Random number generator without duplicates? (From: email@hidden)

  • Prev by Date: Re: Random number generator without duplicates?
  • Next by Date: Re: zapping gremlins
  • Previous by thread: Random number generator without duplicates?
  • Next by thread: Re: Random number generator without duplicates?
  • Index(es):
    • Date
    • Thread