MlbendGenerative.groups_of: def of mlbend-generative@0.1.1.0 Import: import mlbend-generative@0.1.1.0/main.bend as MlbendGenerative Lines 275-288 of mlbend-generative@0.1.1.0/main.bend: https://jend.leeeet.dev/read.txt?path=mlbend-generative@0.1.1.0/main.bend&start_line=275&end_line=288 import Base # How many entries the walk emits over n entries. The count recurses on # the count left, exactly as the walk recurses on the list left, and the # two matches (on the count, on the skip) are in the same order — that # is what lets the law below follow both by induction. def groups_of(+n: Nat, +k: Nat, +skip: Nat) -> Nat: match n: case 0n: 0n case 1n+m: match skip: case 0n: (1n + groups_of(m, k, Nat.sub(k, 1n)) : Nat) case 1n+r: groups_of(m, k, r) Uses (3): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.sub