diff --git a/pkg/arrayx/linq.go b/pkg/arrayx/linq.go index e4c9de2..2d3e8a7 100644 --- a/pkg/arrayx/linq.go +++ b/pkg/arrayx/linq.go @@ -6,3 +6,11 @@ func Last[T any](l []T) T { } return l[len(l)-1] } + +func Map[T any, K any](from []T, tx func(T) K) []K { + var v []K + for _, t := range from { + v = append(v, tx(t)) + } + return v +}