Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Applescript > Re: applescript...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 1606 of 1647
Post > Topic >>

Re: applescript remove duplicate list items

by Dave Balderstone <dave@[EMAIL PROTECTED] > Apr 28, 2008 at 05:25 PM

In article <2008042815593316807-phantom@[EMAIL PROTECTED]
>, Phantom
<phantom@[EMAIL PROTECTED]
> wrote:

> I'm wondering if anyone here knows of an elegant way to eliminate 
> duplicate values from an applescript list.
> 
> e.g. taking this list:
> {"apple", "orange", "apple", "watermelon", "orange"}
> 
> and returning
> {"apple", "orange", "watermelon"}
> 
> 
> not a big priority, but it would help with one of my scripts. could't 
> find a answer with google, unfortunately, sorry to bother if this comes 
> up a lot.
> 
> thanks guys.

Try this:

set list1 to {"apple", "orange", "apple", "watermelon", "orange"}
set list2 to {"apple", "orange", "watermelon"}
set list3 to {}

repeat with x from 1 to count of items of list1
set n to item x of list1
if n is in list2 and n is not in list3 then set end of list3 to n
end repeat

return list3

-- 
Help improve usenet. Kill-file Google Groups.
http://improve-usenet.org/
 




 5 Posts in Topic:
applescript remove duplicate list items
Phantom <phantom@[EMAI  2008-04-28 22:59:33 
Re: applescript remove duplicate list items
Dave Balderstone <dave  2008-04-28 17:25:43 
Re: applescript remove duplicate list items
simon@[EMAIL PROTECTED]   2008-04-29 00:56:07 
Re: applescript remove duplicate list items
Dave Balderstone <dave  2008-04-28 18:08:33 
Re: applescript remove duplicate list items
Phantom <phantom@[EMAI  2008-05-01 03:43:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 12:46:52 CDT 2008.