(def items [1 2 3 4 4 5 5 5])
(def c (count (set items)))
func count[T comparable](items []T) int {
distinct := make(map[T]bool)
for _, v := range items {
distinct[v] = true
}
return len(distinct)
}
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.
(def items [1 2 3 4 4 5 5 5]) (def c (count (set items)))
int c = items.Distinct().Count();
var c = items.toSet().length;
c = items |> Enum.uniq |> length
func count[T comparable](items []T) int { distinct := make(map[T]bool) for _, v := range items { distinct[v] = true } return len(distinct) }
distinct := make(map[T]bool) for _, v := range items { distinct[v] = true } c := len(distinct)
c = count . nub $ items
const c = new Set(items).size;
long c = items.stream().distinct().count();
val c = items.distinct().size
local c=#items
$c = count(array_unique($items));
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.
my $c = scalar(uniq @items);
c = len({*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
c = len(set(items))
c = items.uniq.count
let c = items.iter().unique().count();