mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
784 B
784 B
name, slug, sourceRef, category, subCategory, signatures, variantHelpers, playUrl, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | variantHelpers | playUrl | similarHelpers | position | ||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Interleave | interleave | it/seq.go#L26 | it | sequence |
|
https://go.dev/play/p/kNvnz4ClLgH |
|
173 |
Interleave round-robin alternating input sequences and sequentially appending value at index into result.
seq1 := func(yield func(int) bool) {
yield(1)
yield(3)
}
seq2 := func(yield func(int) bool) {
yield(2)
yield(4)
}
seq3 := func(yield func(int) bool) {
yield(5)
yield(6)
}
interleaved := it.Interleave(seq1, seq2, seq3)
var result []int
for item := range interleaved {
result = append(result, item)
}
// result contains [1, 2, 5, 3, 4, 6]