From a451f14888189f8271fa768ff2aea0a172741f9d Mon Sep 17 00:00:00 2001 From: Alan Date: Sat, 28 Feb 2026 22:34:32 +1100 Subject: [PATCH] fix bug --- huffman.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/huffman.lisp b/huffman.lisp index 1bda7a5..ff3fea0 100644 --- a/huffman.lisp +++ b/huffman.lisp @@ -47,8 +47,8 @@ (progn (setq code (+ code 1)) (when (> ,codelen-form codelen) - (setq codelen ,codelen-form) - (setq code (ash code 1)))) + (setq code (ash code (- ,codelen-form codelen))) + (setq codelen ,codelen-form))) (setq codelen ,codelen-form)) collect (cons ,key-form (cons code codelen))))) ;; (macroexpand '(mkcanon (for pair in sorted-huffman-list while pair) (car pair) (cdr (cdr pair))))