a := []int{1, 2, 3, 4, 5}
b := []float32{1.1, 2.2, 3.3, 4.4, 5.5, 6.6}
for _, p := range pie.Zip(a, b) {
fmt.Println(p)
}
for _, p := range pie.ZipLongest(a, b) {
fmt.Println(p)
}
// {1 1.1}
// {2 2.2}
// {3 3.3}
// {4 4.4}
// {5 5.5}
// {0 6.6} <- 0 is default value not in original slice
It is the same as zip() and itertools.zip_longest in Python
a = [1, 2, 3, 4, 5]
b = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]
for p in zip(a, b):
print(p)
a = [1, 2, 3, 4, 5]
b = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6]
for p in itertools.zip_longest(a, b, fillvalue=0):
print(p)
With
Zip
andZipLongest
function we can do:It is the same as
zip()
anditertools.zip_longest
in Python