There should be a "unique" option on sort . . .

Dr. Hawkins dochawk at
Sun Jan 5 11:19:25 EST 2014

On Sat, Jan 4, 2014 at 8:54 PM, <dunbarx at> wrote:

> And in any case it is simple and fast to delete duplicates, if that is
> what is desired, in a few lines of code.
> The idea of singling out one instance seems more like a job for "filter".
I'd agree with that, too.

But "a few lines of code" is almost always going to be slower than
something actually built in.

What looks fastest to me (not tested) is

assuming sorted data:

repeat with i = the number of lines of stuff down to 1
   put line i of stuff into newLn
   if newLn = oldLn then delete line i of stuff
   put newLn into oldLn
next repeat

you could also

unsorted data:

repeat for each line line theLn in stuff
    if theLn is not among the lines of newStuff then put cr & theLn after
end repeat

Each of these, though, seems to be doing a search each time, while the info
was already there while the intrinsic sorted.

nice would be

repeat for each line theLn in stuff BACKWARDS

which would allow a single pass through, and an appending of non-unique
lines (with sorted data)
Dr. Richard E. Hawkins, Esq.
(702) 508-8462

More information about the Use-livecode mailing list