v0.0.86
This commit is contained in:
parent
bf16a8165f
commit
4fd768e573
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user