From ee325f67fd08cd4d33860b54ed8c2549729f708e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Thu, 9 Mar 2023 14:51:53 +0100 Subject: [PATCH] v0.0.90 --- langext/array.go | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 {