• 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: kai <email@hidden>
  • Date: Wed, 27 Oct 2004 06:58:15 +0100


On Tue, 26 Oct 2004 23:03:23 -0400, David Andrews <email@hidden> wrote:


On Oct 26, 2004, at 10:45 PM, kai wrote:

[snip]
Try:

some paragraph of "1
2
3
4
5
6"

;-)

---
kai


And I'll try some character as well:

...
set nums to {1, 2, 3, 4, 5, 6}
set numss to "1 2 3 4 5 6"
set numsp to "1
2
3
4
5
6"
set numsc to "123456"
...
	--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 roll to some paragraph of numsp -->
	--{{100025, 99924, 100171, 99564, 100307, 100009}, 40}

	set roll to some character of numsc -->
	--{{100016, 100070, 100107, 99883, 100047, 99877}, 43}

...

Not bad, if there were not some item! :)

Hm... 'some paragraph' has the edge OMM - although my test differs from yours somewhat. (I'm comparing just the core statements without assigning any frequency data. I'm also using 'the ticks' from Jon's Commands for greater accuracy. No biggie, though - there may still be other OS/machine level differences at play here.)


Obviously, the above methods return values of different classes: either an integer or a string. So if an additional coercion was required (either one way or the other) it would impact on the performance of a given method, too.

More importantly, the fastest method in any other situation would depend largely on the range of numbers involved.

For example, I'd be willing to wager that the relationship between 'some item' and 'some paragraph' shifts if you extend the number range from 1-6 to, say, 1-20.

For similar reasons, 'random number' isn't particularly competitive when the range is limited, but comes into its own as the range increases - and is extremely effective when hundreds of numbers are involved. In fact, there seems to be be very little variation in the time taken to generate a random number - be it from 2 or 2000 numbers. By contrast, the execution of list methods can take significantly longer as list length increases.

---
kai

_______________________________________________
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


  • Follow-Ups:
    • Re: Dice
      • From: Malcolm Fitzgerald <email@hidden>
  • Prev by Date: Re: Dice
  • Next by Date: Re: [~ot] those pesky invisible folders ...
  • Previous by thread: Re: Dice
  • Next by thread: Re: Dice
  • Index(es):
    • Date
    • Thread