diff --git a/langext/array.go b/langext/array.go index a8a0e54..7f53a06 100644 --- a/langext/array.go +++ b/langext/array.go @@ -295,6 +295,16 @@ func ArrFilterMap[T1 any, T2 any](arr []T1, filter func(v T1) bool, conv func(v return r } +func ArrFilter[T any](arr []T, filter func(v T) bool) []T { + r := make([]T, 0, len(arr)) + for _, v := range arr { + if filter(v) { + r = append(r, v) + } + } + return r +} + func ArrSum[T NumberConstraint](arr []T) T { var r T = 0 for _, v := range arr {