deleteDups()

Geoff Canyon gcanyon at inspiredlogic.com
Wed Nov 16 11:24:20 EST 2005


On Nov 16, 2005, at 7:29 AM, HyperChris at aol.com wrote:

> Chris wrote:
> function deleteDups pList
>     repeat with x=number of lines in pList down to 2
>     if line x of pList is line (x-1) of pList then delete line x of  
> pList
>     end repeat
>   return pList
> end deleteDups
>
> then Eric Chatonet wrote ...
> function deleteDups pList
>   local tLine,tStrippedList
>   -----
>   repeat for each line tLine in pList
>      if tLine is not among the lines of tStrippedList
>      then put tLine & cr after tStrippedList
>    end repeat
>   return word 1 to -1 of tStrippedList
> end deleteDups
>
> then J. Landman Gay wrote ...
> function deleteDups pList
>    split pList by cr and numToChar(3)
>    return keys(pList)
> end deleteDups
>
>
> You have enlarged my universe. Using "for each" is several orders of
> magnitude faster than my original script and "split" is faster still.

Bother -- it happened again. First we had repeat for each turning up  
faster than the filter command. Now I've done a test on the  
following, and it looks like the split command takes not quite twice  
as long as repeat for each (when repeat for each is handled the  
following way).

function deleteDupes pList -- does _not_ retain sort order
   repeat for each line L in pList
     put 1 into temp[L]
   end repeat
   return the keys of temp
end deleteDupes





More information about the use-livecode mailing list