remove
This commit is contained in:
parent
b85c13a047
commit
066eb8688c
|
@ -1,9 +1,6 @@
|
||||||
package parallel
|
package parallel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
|
|
||||||
"git.tuxpa.in/a/lambda"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var routineCount int = 1
|
var routineCount int = 1
|
||||||
|
@ -11,32 +8,3 @@ var routineCount int = 1
|
||||||
func SetRoutineCount(n int) {
|
func SetRoutineCount(n int) {
|
||||||
routineCount = n
|
routineCount = n
|
||||||
}
|
}
|
||||||
func Foldl[T any](xs []T, fx func(T, T) T) T {
|
|
||||||
spl := lambda.Split(xs, routineCount)
|
|
||||||
wg := new(sync.WaitGroup)
|
|
||||||
wg.Add(len(spl))
|
|
||||||
tmp := make([]T, len(spl))
|
|
||||||
for i, v := range spl {
|
|
||||||
go func(ix int, vx []T) {
|
|
||||||
tmp[ix] = lambda.Foldl(vx, fx)
|
|
||||||
wg.Done()
|
|
||||||
}(i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
return lambda.Foldl(tmp, fx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Foldr[T any](xs []T, fx func(T, T) T) T {
|
|
||||||
spl := lambda.Split(xs, routineCount)
|
|
||||||
wg := new(sync.WaitGroup)
|
|
||||||
wg.Add(len(spl))
|
|
||||||
tmp := make([]T, len(spl))
|
|
||||||
for i, v := range spl {
|
|
||||||
go func(ix int, vx []T) {
|
|
||||||
tmp[ix] = lambda.Foldr(vx, fx)
|
|
||||||
wg.Done()
|
|
||||||
}(i, v)
|
|
||||||
}
|
|
||||||
wg.Wait()
|
|
||||||
return lambda.Foldr(tmp, fx)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue