• 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: Dice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dice


  • Subject: Re: Dice
  • From: David Andrews <email@hidden>
  • Date: Tue, 26 Oct 2004 21:46:01 -0400

On Oct 26, 2004, at 3:10 AM, Michelle Steiner wrote:

Hmm, which of the following is the fastest?

random number from 1 to 6
some word of "1 2 3 4 5 6"
some item of {1,2,3,4,5,6}

For very large ranges, the first is the easiest to type.

-- Michelle

On Oct 26, 2004, at 2:54 PM, Tom Humiston wrote:

set freq to {0, 0, 0, 0, 0, 0}
repeat 10000 times
	set roll to random number from 1 to 6
	set item roll of freq to (contents of item roll of freq) + 1
end repeat
freq
[snip]
I used "some item" instead of "random number" and the script runs much faster -- about 1 sec. vs. about 1.5 min.

set freq to {0, 0, 0, 0, 0, 0}
set nums to {1, 2, 3, 4, 5, 6}
repeat 10000 times
	set roll to some item of nums
	set item roll of freq to (contents of item roll of freq) + 1
end repeat
freq
[snip]
- Tom

OMM:

set freq to {0, 0, 0, 0, 0, 0}
set nums to {1, 2, 3, 4, 5, 6}
set numss to "1 2 3 4 5 6"
set tStart to (current date)
repeat 600000 times
	--set roll to random number from 1 to 6 -->
	--{{100218, 100223, 99687, 99897, 99802, 100173}, 73}

	--set roll to some word of numss -->
	--{{99582, 100278, 100027, 100086, 100208, 99819}, 95}

	set roll to some item of nums -->
	--{{99731, 100335, 99784, 100104, 100027, 100019}, 22}

	set item roll of freq to (contents of item roll of freq) + 1
end repeat
set rTime to (current date) - tStart
{freq, rTime}

So "some item of nums" is much faster that the other two techniques.

David A

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re:Dice (From: Kevin <email@hidden>)
 >Re: Dice (From: Adrian Milliner <email@hidden>)
 >Re: Dice (From: Robert Poland <email@hidden>)
 >Re: Dice (From: "Adam K. Wuellner" <email@hidden>)
 >Re: Dice (From: Tom Humiston <email@hidden>)

  • Prev by Date: Re: Setting the default signature in Entourage
  • Next by Date: Re: Dice
  • Previous by thread: Re: Dice
  • Next by thread: Re: Dice
  • Index(es):
    • Date
    • Thread