summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDaniel Santos <dacs.git@brilhante.top>2023-01-09 22:14:25 +0000
committerDaniel Santos <dacs.git@brilhante.top>2023-01-09 22:14:25 +0000
commit8be733f5ae19d06c0972b30925f16f0ca2687d77 (patch)
tree1033b1bbeca1119d756331ab389e6c2398d90433
parentcf250cf41f97f3918df2c9386e09c34bd7bc580f (diff)
downloadcl-math-8be733f5ae19d06c0972b30925f16f0ca2687d77.tar.gz
plus-decimal and plus-earth sums many numbers
The functions plus-decimal and plus-earth now supports many arguments to do it's sum.
It uses the &rest argument.
-rw-r--r--cl-math.lisp12
1 files changed, 6 insertions, 6 deletions
diff --git a/cl-math.lisp b/cl-math.lisp
index 61a8e26..a217df4 100644
--- a/cl-math.lisp
+++ b/cl-math.lisp
@@ -85,10 +85,10 @@
 	  (plus numerals number1 number2)
 	  :initial-value 0))
 
-(defun plus-decimal (a b)
-  "Given 2 decimal numbers, it returns it's sum."
-  (plus-number '(0 1 2 3 4 5 6 7 8 9) a b))
+(defun plus-decimal (&rest args)
+  "Given decimal numbers, it returns it's sum."
+  (reduce (lambda (a b) (plus-number '(0 1 2 3 4 5 6 7 8 9) a b)) args))
 
-(defun plus-earth (a b)
-  "Give 2 earthal numbers, it returns it's sum."
-  (plus-number '(1 2 3 4 5) a b))
+(defun plus-earth (&rest args)
+  "Give earthal numbers, it returns it's sum."
+  (reduce (lambda (a b) (plus-number '(1 2 3 4 5) a b)) args))