Files
lo/docs/data/core-zipbyx.md
T
2026-03-02 16:06:51 +01:00

1.9 KiB

name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
name slug sourceRef category subCategory signatures playUrl variantHelpers similarHelpers position
ZipByX zipbyx tuples.go#L335 core tuple
func ZipBy2[A any, B any, Out any](a []A, b []B, predicate func(a A, b B) Out) []Out
func ZipBy3[A any, B any, C any, Out any](a []A, b []B, c []C, predicate func(a A, b B, c C) Out) []Out
func ZipBy4[A any, B any, C any, D any, Out any](a []A, b []B, c []C, d []D, predicate func(a A, b B, c C, d D) Out) []Out
func ZipBy5[A any, B any, C any, D any, E any, Out any](a []A, b []B, c []C, d []D, e []E, predicate func(a A, b B, c C, d D, e E) Out) []Out
func ZipBy6[A any, B any, C any, D any, E any, F any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, predicate func(a A, b B, c C, d D, e E, f F) Out) []Out
func ZipBy7[A any, B any, C any, D any, E any, F any, G any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, predicate func(a A, b B, c C, d D, e E, f F, g G) Out) []Out
func ZipBy8[A any, B any, C any, D any, E any, F any, G any, H any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, predicate func(a A, b B, c C, d D, e E, f F, g G, h H) Out) []Out
func ZipBy9[A any, B any, C any, D any, E any, F any, G any, H any, I any, Out any](a []A, b []B, c []C, d []D, e []E, f []F, g []G, h []H, i []I, predicate func(a A, b B, c C, d D, e E, f F, g G, h H, i I) Out) []Out
https://go.dev/play/p/wlHur6yO8rR
core#tuple#zipbyx
core#tuple#zipbyerrx
core#tuple#tuplex
core#tuple#unpackx
core#tuple#zipx
core#tuple#unzipx
core#tuple#unzipbyx
core#slice#map
core#slice#filtermap
31

Zips multiple slices and projects each grouped set through a function. Variants support 2 up to 9 input slices.

Variants: ZipBy2..ZipBy9

xs := []int{1,2}
ys := []string{"a","b"}
pairs := lo.ZipBy2(xs, ys, func(x int, y string) string {
    return fmt.Sprintf("%d-%s", x, y)
})