Back to Lo

It Zipx

docs/data/it-zipx.md

1.53.0542 B
Original Source

Creates a sequence of grouped elements from multiple sequences. The resulting sequence has length equal to the shortest input sequence.

Variants: Zip2..Zip9

go
seq1 := func(yield func(int) bool) {
    _ = yield(1)
    _ = yield(2)
    _ = yield(3)
}
seq2 := func(yield func(string) bool) {
    _ = yield("a")
    _ = yield("b")
    _ = yield("c")
}
zipped := it.Zip2(seq1, seq2)
var result []string
for tuple := range zipped {
    result = append(result, fmt.Sprintf("%d%s", tuple.A, tuple.B))
}
// result contains "1a", "2b", "3c"