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.
use List::Util qw(uniq);
my $c = scalar(uniq @items);
c = len(set(items))
c = []
for x in items:
if x not in c:
c.append(x)
c = len(c)
c = 0
for a, x in enumerate(items):
if x not in items[a + 1:]:
c = c + 1
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.