def bitw.popcount
import bend-osdev-algo@0.1.0.0/algo.bend as Algoimport Base
44def bitw.popcount(n: Nat, w: Word(n)) -> Nat:
45 match n:
46 case 0n:
47 0n
48 case 1n+p:
49 match w:
50 case WCon{b, t}:
51 bitw.popcount.step(b, bitw.popcount(p, t))