This commit is contained in:
Mike Schwörer 2023-02-14 17:18:58 +01:00
parent bf16a8165f
commit 4fd768e573
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF

View File

@ -290,3 +290,19 @@ func ArrSum[T NumberConstraint](arr []T) T {
}
return r
}
func ArrFlatten[T1 any, T2 any](arr []T1, conv func(v T1) []T2) []T2 {
r := make([]T2, 0, len(arr))
for _, v1 := range arr {
r = append(r, conv(v1)...)
}
return r
}
func ArrFlattenDirect[T1 any](arr [][]T1) []T1 {
r := make([]T1, 0, len(arr))
for _, v1 := range arr {
r = append(r, v1...)
}
return r
}