From bf16a8165fcfb5ade829116e2772926b32ac136b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 14 Feb 2023 16:25:45 +0100 Subject: [PATCH] v0.0.85 --- langext/array.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/langext/array.go b/langext/array.go index 3a28739..af12982 100644 --- a/langext/array.go +++ b/langext/array.go @@ -265,6 +265,14 @@ func ArrMap[T1 any, T2 any](arr []T1, conv func(v T1) T2) []T2 { return r } +func ArrMapExt[T1 any, T2 any](arr []T1, conv func(idx int, v T1) T2) []T2 { + r := make([]T2, len(arr)) + for i, v := range arr { + r[i] = conv(i, v) + } + 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 {