Files
lo/docs/data/it-flatten.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

648 B

name, slug, sourceRef, category, subCategory, signatures, variantHelpers, playUrl, similarHelpers, position
name slug sourceRef category subCategory signatures variantHelpers playUrl similarHelpers position
Flatten flatten it/seq.go#L26 it sequence
func Flatten[T any, I ~func(func(T) bool)](collection []I) I
https://go.dev/play/p/CCklxuNk7Lm
core#slice#flatten
172

Flatten returns a sequence a single level deep.

seq1 := func(yield func(int) bool) {
    yield(1)
    yield(2)
}
seq2 := func(yield func(int) bool) {
    yield(3)
    yield(4)
}

flattened := it.Flatten([]iter.Seq[int]{seq1, seq2})
var result []int
for item := range flattened {
    result = append(result, item)
}
// result contains [1, 2, 3, 4]