mirror of
https://github.com/rjNemo/underscore
synced 2026-06-06 18:46:47 +00:00
12 lines
315 B
Go
12 lines
315 B
Go
package underscore
|
|
|
|
// Intersection computes the list of values that are the intersection of all the slices.
|
|
// Each value in the result is present in each of the slices.
|
|
func Intersection[T comparable](a, b []T) (res []T) {
|
|
for _, n := range a {
|
|
if Contains(b, n) {
|
|
res = append(res, n)
|
|
}
|
|
}
|
|
return res
|
|
}
|