claptrap-go/utils/slices.go
2024-07-08 18:09:43 +02:00

12 lines
148 B
Go

package utils
func Filter[T any](s []T, f func(T) bool) []T {
var r []T
for _, v := range s {
if f(v) {
r = append(r, v)
}
}
return r
}