def sum.go

bend-parallel@0.1.0.0 · scan.bend:39

import bend-parallel@0.1.0.0/scan.bend as Scan
import Base

39# r holds the array and the entry x read at j: adds x and the n entries
40# after it to s. Returns the array and the sum.
41def sum.go(+n: Nat, +j: U32, +s: U32, r: Array<U32> & U32) -> Array<U32> & U32:
42  match n:
43    case 0n:
44      (a, +x) = r
45      (a, (s + x : U32))
46    case 1n+p:
47      (a, +x) = r
48      +q = (j + 1 : U32)
49      sum.go(p, q, (s + x : U32), a[q])

Uses (7)

Used by (1)