This commit is contained in:
Mike Schwörer 2023-03-09 14:51:53 +01:00
parent dba0cd229e
commit ee325f67fd
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -295,6 +295,16 @@ func ArrFilterMap[T1 any, T2 any](arr []T1, filter func(v T1) bool, conv func(v
return r 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 { func ArrSum[T NumberConstraint](arr []T) T {
var r T = 0 var r T = 0
for _, v := range arr { for _, v := range arr {