mirror of
https://github.com/samber/lo.git
synced 2026-04-22 15:37:14 +08:00
fa095e4b4f
* fix(doc): fix go playground demo URL * fix(doc): add more go playground demo URL
2.5 KiB
2.5 KiB
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CrossJoinByX | crossjoinbyx | it/tuples.go#L439 | it | tuple |
|
https://go.dev/play/p/6QGp3W-bQU1 |
|
|
20 |
Combines every item from multiple lists (cartesian product) using a callback function to transform the results. Returns an empty sequence if any input sequence is empty.
Variants: CrossJoinBy2..CrossJoinBy9
seq1 := func(yield func(int) bool) {
_ = yield(1)
_ = yield(2)
}
seq2 := func(yield func(string) bool) {
_ = yield("a")
_ = yield("b")
}
result := it.CrossJoinBy2(seq1, seq2, func(i int, s string) string {
return fmt.Sprintf("%d-%s", i, s)
})
var output []string
for item := range result {
output = append(output, item)
}
// output contains ["1-a", "1-b", "2-a", "2-b"]