Sender: |
|
Mime-version: |
1.0 |
Date: |
Wed, 16 Apr 2008 12:55:11 -0700 |
Reply-To: |
|
Content-type: |
text/plain; charset="US-ASCII" |
Subject: |
|
From: |
|
In-Reply-To: |
|
Content-transfer-encoding: |
7bit |
Parts/Attachments: |
|
|
Please disregard the script in my last post, here's the finished working
comparison script:
----------------------------------------------------------------------
property listIndex : {}
set fullDeck to {}
repeat with s in {" of H", " of C", " of S", " of D"}
repeat with x from 1 to 13
if x = 1 then
set c to "A"
else if x = 11 then
set c to "J"
else if x = 12 then
set c to "Q"
else if x = 12 then
set c to "Q"
else if x = 13 then
set c to "K"
else
set c to x as string
end if
set the end of fullDeck to c & s
end repeat
end repeat
set listIndex to {}
repeat with x from 1 to count of fullDeck
set the end of listIndex to x
end repeat
copy fullDeck to aDeck
copy fullDeck to bDeck
set startTime to the ticks
repeat 10 times
set aDeck to ashuffle(aDeck)
end repeat
set aShuffledDeck to the aDeck
set midTime to the ticks
repeat 10 times
set bDeck to bshuffle(bDeck)
end repeat
set bShuffledDeck to the bDeck
set endTime to the ticks
return {midTime - startTime, endTime - midTime, aShuffledDeck,
bShuffledDeck}
on ashuffle(aList)
script o
property l : aList
end script
repeat with i from (count aList) to 2 by -1
set j to (some item of listIndex)
set v to item i of o's l
set item i of o's l to item j of o's l
set item j of o's l to v
end repeat
return o's l
end ashuffle
on bshuffle(aList)
script o
property l : aList
end script
repeat with i from (count aList) to 2 by -1
set j to (random number (i - 1)) + 1
set v to item i of o's l
set item i of o's l to item j of o's l
set item j of o's l to v
end repeat
return o's l
end bshuffle
---------------
ES
|
|
|