deleteDups()
J. Landman Gay
jacque at hyperactivesw.com
Tue Nov 15 17:32:23 EST 2005
HyperChris at aol.com wrote:
> I used to use an Xcmd set called HyperExternals Pro and one of its useful
> XFCN's was deleteDups(). The main thing it did was to quickly eliminate the
> duplicate lines in a sorted list. Here is my transcript replacement ...
> 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
> ... but I thought it might be fun to see what others have to offer up that
> would be more elegant and clever! Anyone?
If you don't care what the final order is, I like this one. It takes
advantage of the fact that the "split" command doesn't allow duplicates
and is very fast:
function deleteDups pList
split pList by cr and numToChar(3)
return keys(pList)
end deleteDups
I use numToChar(3) -- which is the "enter" key -- becaue it is
untypeable and therefore unlikely to be in the data. You could use any
character you know isn't in the list.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list