def mask
import bend-collections-laws-crypto@1.0.0.0/spec/lib/numeric.bend as Numericimport Base
109# The low k bits set, the rest clear.
110def mask(+n: Nat, +k: Nat) -> Word(n):
111 match n k:
112 case 0n _:
113 WNil{}
114 case 1n+p 0n:
115 WCon{False{}, mask(p, 0n)}
116 case 1n+p 1n+j:
117 WCon{True{}, mask(p, j)}