This commit is contained in:
Adam Cooper 2025-01-24 20:02:28 -05:00
parent 577860559e
commit 8cbf0b109b
3 changed files with 24 additions and 6 deletions

View file

@ -95,10 +95,12 @@ One suggested add-on for Emacs and Common Lisp is
with the REPL; making iterative coding and testing very easy.
## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can ask for mentoring to help you come to the correct solution.
[awesome-cl-communities]: https://github.com/GustavBertram/awesome-common-lisp-learning#online-community
[slime]: https://github.com/slime/slime
[track-docs]: /docs/tracks/common-lisp
[track-install]: /docs/tracks/common-lisp/installation
[track-resources]: /docs/tracks/common-lisp/resources
[track-resources]: /docs/tracks/common-lisp/resources

Binary file not shown.

View file

@ -11,8 +11,24 @@
0
(+ (* (first l) (expt base (- (length l) 1)) (conv (rest l) base)))))
(defun unconv (number base exponent)
; (if (eq exponent -1) (calc-start-exponent number base) exponent)
; Slip the above into the following (or assign to new variable):
; (append (list (/ number base**exponent)) (unconv (mod number base**exponent) base (- exponent 1))
)
(defun calc-start-exponent (num base x)
(if (< num (expt base (1+ x)))
x
(calc-start-exponent num base (1+ x))))
(defun unconv (num base exponent)
; TODO
; Compiler calls x and undefined variable, so I need to fix this
; `setq` call.
(setq x
(if (eq exponent -1)
(calc-start-exponent num base 0)
exponent))
(if (eq x 0)
(list num)
(multiple-value-bind (q r)
(truncate (/ num (expt base x)))
(append (list q) (unconv r base (- x 1))))))
(defun rebase (l source destination)
(unconv (conv l source) destination -1))