def sum.one
import bend-parallel@0.1.0.0/sort.bend as Sortimport Base
112# Column c, when c < K: over its nb + 1 entries from o + c, step apart
113# (the groups' last rows, or all the rows of a small table), the total
114# into cs[c] and os[c], by sum.col. Else 0 into both.
115def sum.one(lt: Bool, +wr: Bool, +c: U32, +o: U32, +step: U32, +nb: Nat, p: Three) -> Three:
116 match lt:
117 case True{}:
118 Three{t, cs, os} = p
119 sum.put(c, cs, os, sum.col(wr, (o + c : U32), step, nb, t))
120 case False{}:
121 Three{t, cs, os} = p
122 Three{t, cs[c] <- 0, os[c] <- 0}