def xs.go
import bend-parallel@0.1.0.0/sort.bend as Sortimport Base
86# r holds the table and the entry x read at at: it becomes s, and the n
87# entries after it (each step further on) follow, from s + x. Returns the
88# table and the sum past the last.
89def xs.go(+n: Nat, +at: U32, +step: U32, +s: U32, r: Array<U32> & U32) -> Array<U32> & U32:
90 match n:
91 case 0n:
92 (t, +x) = r
93 (t[at] <- s, (s + x : U32))
94 case 1n+p:
95 (t, +x) = r
96 +q = (at + step : U32)
97 xs.go(p, q, step, (s + x : U32), (t[at] <- s)[q])