Re: Need a faster Find Duplicates Routine
Re: Need a faster Find Duplicates Routine
- Subject: Re: Need a faster Find Duplicates Routine
- From: Ken Tozier <email@hidden>
- Date: Wed, 28 May 2003 01:46:55 -0400
>
> Hey All,
>
>
>
> Anyone know of any samples that will run faster than this? This one
>
> is fine
>
> for under 300 items, but give it 3000 (3k X 3k = painfully
>
> inefficient), and
>
> be prepared to wait... and wait... and wait...
>
>
>
> set theItems to [a list of items]
>
> set dupesList to {}
>
> set checkList to {}
>
> repeat with i from 1 to number of items in theItems
>
> set x to the name of item i of theItems
>
> if x is in checkList then
>
> repeat with i from 1 to number of items in theItems
>
> set y to item i of theItems
>
> if the name of y is x then
>
> set the end of dupesList to y
>
> end if
>
> end repeat
>
> else
>
> copy x to the end of checkList
>
> end if
>
> end repeat
>
>
>
> TIA
>
>
>
> JA
Not sure I fully understand what you're trying to do with this loop,
but if you're objective is to create one list containing a single
instance of every object in the source list and another list with a
single instance of each item that apperars in source list more than
once, the following script does that. Cut and paste it into a new
script, run it and look at the two lists it produces to see if that's
what you're trying to do.
set sourceList to {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"j", "j", "k", "l", "m", "n", "o", "o", "o", "p", "q", "q", "r", "r",
"s", "s"}
set checklist to {}
set dupList to {}
repeat with anItem in sourceList
if (checklist does not contain anItem) then
set checklist to checklist & {anItem as string}
else if (dupList does not contain anItem) then
set dupList to dupList & {anItem as string}
end if
end repeat
{checklist:checklist, dupList:dupList}
KT
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.