• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Comparing 2 Lists
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Comparing 2 Lists (From: Todd Geist <email@hidden>)

  • Prev by Date: Re: Comparing 2 Lists
  • Next by Date: ImageMagick & do shell script.. almost got, it need help
  • Previous by thread: Re: Comparing 2 Lists
  • Next by thread: Re: URL Access/IE5.x download question...
  • Index(es):
    • Date
    • Thread