Tests pass

This commit is contained in:
Adam Cooper 2025-01-27 16:23:28 -05:00
parent 348a973e26
commit 60ca8969a8
2 changed files with 8 additions and 7 deletions

Binary file not shown.

View file

@ -4,9 +4,6 @@
(in-package :all-your-base)
; `rebase` needs to return NIL sometimes. For the cases where one bad list
; item yields NIL, we need `conv` to return multiple values: (ok, val).
; Then we can check the ok before proceeding to `unconv`.`
(defun conv (l base)
(if (null l)
0
@ -29,4 +26,8 @@
(append (list q) (unconv r base (- x 1)))))))
(defun rebase (l source destination)
(unconv (conv l source) destination -1))
(cond ((< source 2) nil)
((< destination 2) nil)
((some #'(lambda (x) (< x 0)) l) nil)
((some #'(lambda (x) (>= x source)) l) nil)
(t (unconv (conv l source) destination -1))))