Eliminating Duplicates from a List

I’m having a brain spasm because this should be straightforward and I keep coming up with kluges.
What makes it all the more frustrating is that I’ve seen the answer before and I can’t find it (in my
experience, thinking you know or have the answer somewhere is a great barrier to creativity).

Problem: a sorted list like {0, 0, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 8, 9, 9} has duplicate entries and I want only
the subset of unique values, in this case {0, 2, 3, 4, 8, 9}.

What’s an efficient way to crunch this down?

This works for me. I’m certain there is a faster way.

``````set oldList to {0, 0, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 8, 9, 9}
set newList to {}
repeat with myNum from 1 to length of oldList
set myItem to item myNum of oldList
if newList does not contain myItem then set the end of newList to myItem
end repeat
newList
``````

Best wishes

John M

If there is a faster way, I don’t need it for the sizes of lists I’m playing with. Thanks.

The element I was missing in my solution attempts was “does not contain”.
I was brute force comparing adjacent pairs.