def base.go
import bend-parallel@0.1.0.0/sort.bend as Sortimport Base
158# r holds the table and x, the entry a row (step) above at, which holds
159# the group's running sum through that row: at becomes s + x, and so up
160# for the n rows above; the group's first row, the next above, becomes s.
161def base.go(+n: Nat, +at: U32, +step: U32, +s: U32, r: Array<U32> & U32) -> Array<U32>:
162 match n:
163 case 0n:
164 (t, +x) = r
165 base.fin((at - step : U32), s, t[at] <- (s + x : U32))
166 case 1n+p:
167 (t, +x) = r
168 +q = (at - step : U32)
169 base.go(p, q, step, s, (t[at] <- (s + x : U32))[(q - step : U32)])