Files
lo/docs/data/it-countvalues.md
T
2025-10-06 17:16:33 +02:00

598 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers similarHelpers position
CountValues countvalues it/seq.go#L720 it slice
func CountValues[T comparable](collection iter.Seq[T]) map[T]int
core#slice#countvalues
203

CountValues counts the number of each element in the collection.

collection := func(yield func(string) bool) {
    yield("apple")
    yield("banana")
    yield("apple")
    yield("cherry")
    yield("banana")
    yield("apple")
}

counts := it.CountValues(collection)
// counts contains {"apple": 3, "banana": 2, "cherry": 1}