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
998 B
998 B
name, slug, sourceRef, category, subCategory, signatures, playUrl, variantHelpers, similarHelpers, position
| name | slug | sourceRef | category | subCategory | signatures | playUrl | variantHelpers | similarHelpers | position | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Intersect | intersect | it/intersect.go#L78 | it | intersect |
|
https://go.dev/play/p/kz3cGhGZZWF |
|
|
10 |
Returns the intersection between given collections (elements present in all collections).
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)
}
intersection := it.Intersect(seq1, seq2, seq3)
var result []int
for v := range intersection {
result = append(result, v)
}
// result contains 2, 3 (elements present in all sequences)