• 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
Removing items from a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Removing items from a list


  • Subject: Removing items from a list
  • From: Michelle Steiner <email@hidden>
  • Date: Sat, 6 Mar 2004 14:09:43 -0700

This came up on the Applescript newsgroup. Someone wanted to be able to remove all instances of certain items from a list. Here was my solution; I'm sure I'm not the first person to have come up with it.

set x to {"fu", "foo", "bar", "fu", "foobar", "fubar"}

-- remove items matching "fu" and "fubar" from x
set z to {"fu", "foobar"}
set xx to {}
repeat with a in x
if a is not in z then
copy contents of a to end of xx
end if
end repeat
xx

--> {"foo", "bar", "fubar"}

Too bad "whose" and the like don't work on lists...

-- Michelle

--
"My country, right or wrong: if right, to be kept right; and if wrong, to be set right."
Senator Carl Schurz of Missouri, 1899
_______________________________________________
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.


  • Follow-Ups:
    • Re: Removing items from a list
      • From: Jason Bourque <email@hidden>
    • Re: Removing items from a list
      • From: Steve Meyer <email@hidden>
  • Prev by Date: Text into Mail message content
  • Next by Date: Re: Text into Mail message content
  • Previous by thread: Re: Text into Mail message content
  • Next by thread: Re: Removing items from a list
  • Index(es):
    • Date
    • Thread