Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Pascal
uses classes;
var
  x: TList;
begin
  for i:= x.count-1 downto 0 do
    if x.indexOf(x.items[i]) <> -1 then
      x.delete(i);
end;

Deduplication must start from the back.

Order is preserved because TList is not a map but an array of pointer.
(distinct x)

New implementation...
< >
programming-idioms.org