def par_reduce.list.top
import bend-kit-concurrency@0.2.0.0/concurrency.bend as Concurrencyimport Base
99def par_reduce.list.top(~A: Data, ~f: A -> A -> A, d: Nat, +z: A, nx: Nat & List<A>) -> A:
100 match d:
101 case 0n:
102 (n, xs) = nx
103 fold(~A, ~f, xs, z)
104 case 1n+p:
105 (+n, xs) = nx
106 +h = Nat.div(n, 2n)
107 par_reduce.list.go(~A, ~f, p, h, Nat.sub(n, h), z, split(A, xs, h))