This commit is contained in:
兔子
2024-05-08 14:21:55 +08:00
parent 8619a72a30
commit 40dc74b0bf
3 changed files with 13 additions and 0 deletions

View File

@@ -78,3 +78,13 @@ func ArrayReverse[T any](array []T) (slice []T) {
}
return array
}
// ArrayDiff - 数组差集
func ArrayDiff[T any](array1, array2 []T) (slice []T) {
for _, item := range array1 {
if !InArray(item, array2) {
slice = append(slice, item)
}
}
return slice
}