Removing items from a list
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.