BendMlLlama.halvings: def of bend-ml-llama@0.2.1.0 Import: import bend-ml-llama@0.2.1.0/main.bend as BendMlLlama Lines 841-855 of bend-ml-llama@0.2.1.0/main.bend: https://jend.leeeet.dev/read.txt?path=bend-ml-llama@0.2.1.0/main.bend&start_line=841&end_line=855 import Base import bend-ml-tensor-array@0.1.19.0/main.bend as TA # how many times n groups are halved (the larger half kept) until one or none is left def halvings(fuel: Nat, +n: Nat) -> Nat: match fuel: case 0n: 0n case 1n+f: match n: case 0n: 0n case 1n+p: match p: case 0n: 0n case 1n+q: 1n+halvings(f, Nat.sub(2n+q, TA.half(2n+q))) 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.sub https://jend.leeeet.dev/definition.txt?path=bend-ml-tensor-array@0.1.19.0/main.bend&name=half