From f3909a9b8ed8bb940ee126b9dfbe131a666b7478 Mon Sep 17 00:00:00 2001 From: Daniel Santos Date: Sat, 25 Feb 2023 16:16:23 +0000 Subject: add div, the division operation --- plus-inc.lisp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plus-inc.lisp b/plus-inc.lisp index 1d37417..ddfb835 100644 --- a/plus-inc.lisp +++ b/plus-inc.lisp @@ -104,3 +104,9 @@ (defun tab (fn a) (dotimes (b 5) (format t "~d . ~d = ~d~%" (1+ b) a (funcall fn (1+ b) a)))) + +(defun div (a b &optional (cycle 1)) + "Division between a and b from any numerical system." + (cond + ((< (- a (1- b)) cycle) (values (1- cycle) (- a (1- cycle)))) + (t (div (- a (1- b)) b (1+ cycle))))) -- cgit 1.4.1-2-gfad0