filter added
This commit is contained in:
parent
84cc7a9e05
commit
55928776b4
11
filter.go
Normal file
11
filter.go
Normal file
@ -0,0 +1,11 @@
|
||||
package slices
|
||||
|
||||
func Filter[T any](slice []T, f func(T) bool) []T {
|
||||
ret := make([]T, 0, len(slice))
|
||||
for _, v := range slice {
|
||||
if f(v) {
|
||||
ret = append(ret, v)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user