• 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: Unique items in list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unique items in list


  • Subject: Re: Unique items in list
  • From: John Stewart <email@hidden>
  • Date: Thu, 21 Oct 2004 16:51:07 -0400

On 10/21/04 at -0700 Eric Geoffroy said this

>Golly I should be able to handle this simple task but I'm failing.
>
>I have a long list that has a lot of dupes. I needs to be narrowed to
>unique items. I've tried to ways to attack this.
>
>Method A: Works, but I end up with a column of results that I can't
>coerce back into a list.
>
>repeat with x in finals
>   set end of finals to x & ", "
>end repeat
>set finals to (do shell script "echo " & (quoted form of (finals as
>string) & " | " & "sort -u"))
>
>
>
>
>Method B: Doesn't work at all.
>
>set finals to {1, 5, 5, 5, 6, 66, 999}
>set juz to {}
>
>repeat with x in finals
>   if x is not in juz then set end of juz to x
>end repeat
>contents of ju


Using the List & Record tools osax from Latenight Software -

set finals to {1, 5, 5, 5, 6, 66, 999}
set dummy to {}
return union of finals and dummy with removing duplicates

--> {1, 5, 6, 66, 999}

<http://www.latenightsw.com/freeware/RecordTools/index.html>

You can also accomplish this with vanilla AppleScript. To do so you need to
iterate through the list and test every item against every other item. Since I
haven't time to write and test such a script tonight perhaps someone else will
post a vanilla example.

On a really large list I suspect the osax version might actually be faster than
vanilla but I have no data to support that. This would not usually be the case
due to the overhead involved in calling the osax.

JBS
--
Why isn't the number 11 pronounced onety one? - George Carlin
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Unique items in list (From: Eric Geoffroy <email@hidden>)

  • Prev by Date: Re: Unique items in list
  • Next by Date: Re: Fraction Maker
  • Previous by thread: Re: Unique items in list
  • Next by thread: Legacy conversion of Quark 4 to InDesign 2 files question
  • Index(es):
    • Date
    • Thread