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

Re: Eliminating duplicate items from a list


  • Subject: Re: Eliminating duplicate items from a list
  • From: "Nigel Garvey" <email@hidden>
  • Date: Wed, 5 Sep 2007 13:04:20 +0100

"Mark J. Reed" wrote on Tue, 4 Sep 2007 09:07:58 -0400:

>Now that I'm more awake/caffeinated, it occurs to me that AS will
>happily do the inner loop for you:
>
>set uniqueList to {}
>repeat with origItemRef in origList
>    set origItem to contents of origItemRef
>    if uniqueList does not contain origItem then
>        set end of uniqueList to origItem
>    end
>end
>
>Which doesn't change the runtime, but does make it simpler to write.

  on zapDuplicates(origList)
    set uniqueList to {}
    script o
      property ol : origList
      property ul : uniqueList
    end script

    repeat with i from 1 to (count origList)
      set origItem to item i of o's ol
      if ({origItem} is in uniqueList) then
      else
        set end of o's ul to origItem
      end if
    end repeat

    return uniqueList
  end zapDuplicates

I'm sure the OSAX suggestion's much faster though.  :)

NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: System Proxy Settings
  • Next by Date: Select a path in browser
  • Previous by thread: Re: Eliminating duplicate items from a list
  • Next by thread: Re: Eliminating duplicate items from a list
  • Index(es):
    • Date
    • Thread