mirror of
https://github.com/samber/lo.git
synced 2026-04-22 23:47:11 +08:00
d99edab80d
* feat(intersectby): form transform callback in first position and add support for vaarg * feat(it): adding loit.IntersectBy * doc: adding lo.IntersectBy + loit.IntersectBy * doc: adding lo.IntersectBy + loit.IntersectBy * style: fix linter * doc: adding example for lo.IntersectBy
1.0 KiB
1.0 KiB
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| IntersectBy | intersectby | it/intersect.go#L78 | it | intersect |
|
|
|
10 |
Returns the intersection between given collections using a custom key selector function.
Examples:
seq1 := func(yield func(int) bool) {
_ = yield(1)
_ = yield(2)
_ = yield(3)
_ = yield(4)
}
seq2 := func(yield func(int) bool) {
_ = yield(2)
_ = yield(3)
_ = yield(5)
}
seq3 := func(yield func(int) bool) {
_ = yield(3)
_ = yield(2)
_ = yield(6)
}
transform := func(v int) string {
return strconv.Itoa(v)
}
intersection := it.IntersectBy(transform, seq1, seq2, seq3)
var result []int
for v := range intersection {
result = append(result, v)
}
// result contains 2, 3 (elements present in all sequences)