• 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(still?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Random number generator without duplicates(still?)


  • Subject: Re: Random number generator without duplicates(still?)
  • From: Ken Dobson <email@hidden>
  • Date: Wed, 18 Apr 2001 23:01:03 -0400

on 4/18/01 2:10 PM, email@hidden at
email@hidden wrote:

>
> The AppleScript user who asked for a suggestion as to how to generate a
> list of 6 random numbers probably doesn't care about any of this.
>
> A simple readable script that produces a list of 6 numbers that are not
> repeated and fall between 1 and 56, and hopefully clarifies the process in
> such a way as to teach the method of it's logic, would have benefited him
> and others on this list much more that this digresive discussion of
> mathematical theory.
--
> In fact Bill, I found your post an informative and clear summary of both
> the accurate and inaccurate information posted on this thread. I just wanted
> to point out how far off the thread had wandered.

As did I..
but back on the subject and to beat the dead horse a tad more. I have script
kicking around here that I wrote one evening while thinking about recursion,
and it's use in helping me pick my lotto numbers :-) I'll snip off just the
pertinent parts and throw it into the mix.

set nList to {}
set nList to NumList(nList, 6)



on NumList(Alist, x)
repeat while (count of Alist) < x
set y to random number from 1 to 56
if Alist does not contain y then
set Alist to Alist & y
else
my NumList(Alist, x)
end if
end repeat
end NumList


  • Prev by Date: Re: Random number generator without duplicates?
  • Next by Date: Setting the startup disk.
  • Previous by thread: Re: How to "remember" a disk alias
  • Next by thread: Setting the startup disk.
  • Index(es):
    • Date
    • Thread