From 72883cf6bd11853451828ac375f72696601e9652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 31 Jan 2023 10:56:30 +0100 Subject: [PATCH] v0.0.73 --- langext/array.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/langext/array.go b/langext/array.go index 3caf34a..3a28739 100644 --- a/langext/array.go +++ b/langext/array.go @@ -265,6 +265,16 @@ func ArrMap[T1 any, T2 any](arr []T1, conv func(v T1) T2) []T2 { return r } +func ArrFilterMap[T1 any, T2 any](arr []T1, filter func(v T1) bool, conv func(v T1) T2) []T2 { + r := make([]T2, 0, len(arr)) + for _, v := range arr { + if filter(v) { + r = append(r, conv(v)) + } + } + return r +} + func ArrSum[T NumberConstraint](arr []T) T { var r T = 0 for _, v := range arr {