Skip to content

Commit

Permalink
feat: support Map
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinZonda committed Nov 19, 2022
1 parent 03cd594 commit 2edc739
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/arrayx/linq.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 2edc739

Please sign in to comment.