Re: Dice
Re: Dice
- Subject: Re: Dice
- From: Joseph Weaks <email@hidden>
- Date: Tue, 26 Oct 2004 17:06:13 -0500
On Oct 26, 2004, at 4:00 PM, Adam K. Wuellner wrote:
On Oct 26, 2004, at 3:27 PM, Bill Briggs wrote:
For further clarification you may want to take a peek at my rather
unrestrained rant under that subject line which was posted Date: Wed,
18 Apr 2001 09:41:10 -0300
Your rant on nomenclature is, of course, true. But, there still exists
the possibility and even the need to pick randomly from the remaining
numbers after one or more have been removed from the set. Consider a
deck of cards:
property theDeck : {}
to draw
if theDeck is {} then set theDeck to {"Ace", "Two", "Three", "Four",
"Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen",
"King"}
set c to count theDeck
set n to random number from 1 to c
set theCard to (item n of theDeck)
if n = 1 then
set theDeck to the rest of theDeck
else if n = c then
set theDeck to items 1 thru -2 of theDeck
else
set theDeck to (items 1 thru (n - 1) of theDeck) & (items (n + 1)
thru -1 of theDeck)
end if
return theCard
end draw
draw
-- "Jack"
theDeck
-- {"Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight",
"Nine", "Ten", "Queen", "King"}
Cheers,
Joe Weaks
_______________________________________________
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: Bill Briggs <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: Graff <email@hidden>) |
| >Re: Dice (From: Emmanuel <email@hidden>) |
| >Re: Dice (From: Graff <email@hidden>) |
| >Re: Dice (From: Bill Briggs <email@hidden>) |
| >Re: Dice (From: "Adam K. Wuellner" <email@hidden>) |