v0.0.87
This commit is contained in:
parent
4fd768e573
commit
22ce2d26f3
@ -273,6 +273,18 @@ func ArrMapExt[T1 any, T2 any](arr []T1, conv func(idx int, v T1) T2) []T2 {
|
||||
return r
|
||||
}
|
||||
|
||||
func ArrMapErr[T1 any, T2 any](arr []T1, conv func(v T1) (T2, error)) ([]T2, error) {
|
||||
var err error
|
||||
r := make([]T2, len(arr))
|
||||
for i, v := range arr {
|
||||
r[i], err = conv(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user