• 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: email@hidden
  • Date: Tue, 4 Sep 2007 08:17:25 -0400

On 9/3/07, Brett Conlon <email@hidden> wrote:
 > In Lotus Programming I can wrap a list in an @Unique(List variable) command
> and it strips out all duplicate items. What is the simplest way to do it in
> AS?
>
> I'm thinking it may have to be with a repeat and using text item delimiters,
> right?

Why would you need TID to compare two items to see if they're the
same?  Are you considering them "the same" if only some part of the
string is equal?

This is a place where an associative array would come in handy again,
but yeah, you can do it with a simple repeat loop. Running time is
proportional to the square of the length of the list, but it should be
good enough for relatively short lists or infrequent execution.

Something like this should work:

-- (code to get origList here)

set uniqueList to {}
repeat with i from 1 to length of origList
    set foundIt to false
repeat with j from 1 to length of uniqueList
    if item j of uniqueList = item i of origList then
  set foundIt to true
   end if
end repeat
if foundIt is false then
set end of uniqueList to item i of origList
end repeat
--
Mark J. Reed <email@hidden>
 _______________________________________________
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

  • Follow-Ups:
    • Re: Eliminating duplicate items from a list
      • From: "Mark J. Reed" <email@hidden>
    • Re: Eliminating duplicate items from a list
      • From: KOENIG Yvan <email@hidden>
References: 
 >Eliminating duplicate items from a list (From: Brett Conlon <email@hidden>)

  • Prev by Date: Re: Eliminating duplicate items from a list
  • Next by Date: Re: Eliminating duplicate items from a list
  • Previous by thread: Re: Eliminating duplicate items from a list
  • Next by thread: Re: Eliminating duplicate items from a list
  • Index(es):
    • Date
    • Thread