github.com/enetx/g@v1.0.80/examples/iter/iter_zip.go (about) 1 package main 2 3 import ( 4 "fmt" 5 6 "github.com/enetx/g" 7 ) 8 9 func main() { 10 // Create two slices of integers 11 slice1 := g.Slice[int]{1, 2, 3}.Iter() 12 slice2 := g.Slice[int]{4, 5, 6}.Iter() 13 14 // Zip the slices in parallel and collect the resulting tuples 15 zipped := slice1.Zip(slice2).Collect() 16 zipped.Print() // MapOrd{1:4, 2:5, 3:6} 17 18 // Iterate over the zipped tuples and print each one 19 for _, v := range zipped { 20 fmt.Println(v) 21 } 22 }