summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniel Santos <dacs.git@brilhante.top>2023-02-25 16:16:23 +0000
committerDaniel Santos <dacs.git@brilhante.top>2023-02-25 16:16:23 +0000
commitf3909a9b8ed8bb940ee126b9dfbe131a666b7478 (patch)
tree403614d13100cd4222600ee3d8d1f68183ba003e
parent737859a9a6ef329b64468800f3513de72b749018 (diff)
downloadcl-math-main.tar.gz
add div, the division operation HEAD main
-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)))))