Number.ones: def of bend-collections-laws-math@1.0.0.0 Import: import bend-collections-laws-math@1.0.0.0/spec/math/number.bend as Number Lines 20-26 of bend-collections-laws-math@1.0.0.0/spec/math/number.bend: https://jend.leeeet.dev/read.txt?path=bend-collections-laws-math@1.0.0.0/spec/math/number.bend&start_line=20&end_line=26 import Base import bend-collections-laws-math@1.0.0.0/spec/lib/common.bend as C # the 1 bits among the k lowest bits of n def ones(k: Nat, +n: Nat) -> Nat: match k: case 0n: 0n case 1n+p: Nat.add(C.bit(n), ones(p, C.half(n))) Uses (4): 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=bend-collections-laws-math@1.0.0.0/spec/lib/common.bend&name=bit https://jend.leeeet.dev/definition.txt?path=bend-collections-laws-math@1.0.0.0/spec/lib/common.bend&name=half