feat: add Merge function

This commit is contained in:
dudaodong committed 2022-11-27 20:20:00 +08:00
1 parent 5722c724e6
commit 7b290989f5
2 files changed
+23

No files matched your search

+11
View File
@@ -618,6 +618,17 @@ func UnionBy[T any, V comparable](predicate func(item T) V, slices ...[]T) []T {
return result
}
// Merge all given slices into one slice
func Merge[T any](slices ...[]T) []T {
result := make([]T, 0)
for _, item := range slices {
result = append(result, item...)
}
return result
}
// Intersection creates a slice of unique values that included by all slices.
func Intersection[T comparable](slices ...[]T) []T {
if len(slices) == 0 {