Update 'parallel/map.go'

This commit is contained in:
a 2022-03-27 01:18:21 +00:00
parent 2d4b3a96cd
commit 117fe3a563

View File

@ -20,14 +20,14 @@ func Map[T any](xs []T, fx func(T) T) []T {
return lambda.Flatten(spl)
}
func MapV[T, V any](xs []T, fx func(T) T) []V {
func MapV[T, V any](xs []T, fx func(T) V) []V {
spl := lambda.Split(xs, routineCount)
wg := new(sync.WaitGroup)
wg.Add(len(spl))
tmp := make([][]V, len(spl))
for i, v := range spl {
go func(ix int, vx []T) {
spl[ix] = lambda.Map(vx, fx)
spl[ix] = lambda.MapV(vx, fx)
wg.Done()
}(i, v)
}