@rivascva/dt-idl 1.1.88 → 1.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go/utils/slices.go +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
package utils
|
|
2
|
+
|
|
3
|
+
// SliceMap applies a function to each element of a slice and returns the results as a new slice.
|
|
4
|
+
func SliceMap[T any, U any](s []T, f func(T) U) []U {
|
|
5
|
+
result := make([]U, len(s))
|
|
6
|
+
for i, v := range s {
|
|
7
|
+
result[i] = f(v)
|
|
8
|
+
}
|
|
9
|
+
return result
|
|
10
|
+
}
|