def huff.codes

gralha-bytes@0.1.0.1 · bytes.bend:167

import gralha-bytes@0.1.0.1/bytes.bend as Bytes
import Base

167def huff.codes(n: Nat, +counts: Bytes, +length: U32, codeword: U32, codes: Bytes) -> Bytes:
168  match n:
169    case 0n: codes
170    case 1n+d:
171      +next = ((codeword + bytes.get(counts, (length - 1 : U32))) * 2 : U32)
172      huff.codes(d, counts, U32.inc(length), next, bytes.push(codes, next))

Uses (9)

Used by (1)