Re: Setting a list to a random order
Re: Setting a list to a random order
- Subject: Re: Setting a list to a random order
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 23 May 2005 16:33:27 -0400
Sure. The Fisher-Yates Shuffle will randomize a list in place, with no need to make a copy:
repeat with i from (count of myList) to 2 by -1
set j to random number from 1 to i
if i /= j then
set temp to item i of myList
set item i of myList to item j of myList
set item j of myList to temp
end if
end repeat
On 5/23/05, Michelle Steiner <email@hidden> wrote:
Steve sent this to me; it is obviously intended for the list.
-- Michelle
Begin forwarded message:
Date: May 23, 2005 12:23:24 PM MST
Subject: Setting a list to
a random order
Hi all
I have to read items from a file which are listed in a sequential order and
randomize them - They appear in the file like this.
6510001460 1 14 $2 coupon
1410011417 2 14 $2 coupon
1210021412 3 14 $2 coupon
1910031454 4 14 $2 coupon
does anyone have a snippet of code that will shuffle a list?
Thanks
--
Help, I've caught a cult, and can't get out!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (
--
Mark J. Reed <
email@hidden>
_______________________________________________
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