function CountUniqueItems(Items: TStrings): Integer;
var
List: TStringList;
begin
List := TStringList.Create;
List.Duplicates := dupIgnore;
List.Sorted := True;
List.AddStrings(Items);
Result := List.Count;
List.Free;
end;
begin
...
c := CountUniqueItems(items);
...
end.
local undupeitems = {}
for _, v in ipairs(items) do
local undupe = true
if #undupeitems == 0 then
table.insert(undupeitems, v)
else
for _, v2 in ipairs(undupeitems) do
if v == v2 then
undupe = false
end
end
if undupe then
table.insert(undupeitems, v)
end
end
end
local c=#undupeitems
function CountUniqueItems(Items: TStrings): Integer;
var
List: TStringList;
begin
List := TStringList.Create;
List.Duplicates := dupIgnore;
List.Sorted := True;
List.AddStrings(Items);
Result := List.Count;
List.Free;
end;
begin
...
c := CountUniqueItems(items);
...
end.
local undupeitems = {}
for _, v in ipairs(items) do
local undupe = true
if #undupeitems == 0 then
table.insert(undupeitems, v)
else
for _, v2 in ipairs(undupeitems) do
if v == v2 then
undupe = false
end
end
if undupe then
table.insert(undupeitems, v)
end
end
end
local c=#undupeitems