Files
lo/docs/data/it-countvalues.md
T
Samuel Berthe fa095e4b4f fix(doc): fix go playground demo URL (#832)
* fix(doc): fix go playground demo URL

* fix(doc): add more go playground demo URL
2026-03-06 00:09:59 +01:00

641 B

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
CountValues countvalues it/seq.go#L720 it slice
func CountValues[T comparable](collection iter.Seq[T]) map[T]int
https://go.dev/play/p/PPBT4Fp-V3B
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}