diff options
Diffstat (limited to 'src/math.lisp')
| -rw-r--r-- | src/math.lisp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/math.lisp b/src/math.lisp index 06931ff..832c87c 100644 --- a/src/math.lisp +++ b/src/math.lisp @@ -31,3 +31,16 @@ (defmacro *= (value &rest numbers) "Multiplies all numbers and stores result in name (first argument)" `(op= '* ,value ,@numbers)) + +(defun ^ (number power) + "Calculates number to the power" + (let ((prod 1)) + (dotimes (x power) + (setq prod (* prod number))) + prod)) + +(defun avg (&rest numbers) + "Calculates the average of all given numbers. If no numbers are given, returns 0." + (if (not numbers) + 0 + (/ (apply '+ numbers) (length numbers)))) |
