summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--plus-inc.lisp6
1 files changed, 6 insertions, 0 deletions
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)))))