12 lines
148 B
Go
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
|
||
|
}
|