Re: Comparing 2 Lists
Re: Comparing 2 Lists
- Subject: Re: Comparing 2 Lists
- From: Michelle Steiner <email@hidden>
- Date: Sat, 24 May 2003 16:00:08 -0700
On Saturday, May 24, 2003, at 11:46 AM, Todd Geist wrote:
I need a way to compare 2 lists and return only the items that are NOT
IN
both lists.
For example:
ListA = {apples, bananas, peaches, grapes, pears}
ListB = {apples, grapes}
The result would be a list = {bananas, peaches, pears}
I modified the lists so there's at least one item in each that is not
in the other.
set listA to {"apples", "pears", "grapes"}
set ListB to {"apples", "grapes", "bananas", "peaches"}
set listC to {}
repeat with listItem in listA
if listItem is not in ListB then
copy contents of listItem to end of listC
end if
end repeat
repeat with listItem in ListB
if listItem is not in listA then
copy contents of listItem to end of listC
end if
end repeat
listC
--> {"pears", "bananas", "peaches"}
--
George Bush == Timothy McVeigh == Saddam Hussein
_______________________________________________
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.