def starts
import bend-visgraph@2.0.0.0/visgraph.bend as Visgraphimport Base
910# The counts of `n` nodes, in place, as where each node's run starts; slot
911# `n` gets the total.
912def starts(count: Nat, +i: U32, r: Array<U32> & U32, +acc: U32) -> Array<U32>:
913 match count:
914 case 0n:
915 (a, c) = r
916 Array.set(U32, a, i, acc)
917 case 1n+k:
918 (a, +c) = r
919 +i2 = (i + 1 : U32)
920 starts(k, i2, Array.get(U32, Array.set(U32, a, i, acc), i2), (acc + c : U32))