Commit d16bee4f authored by Juergen Nickelsen's avatar Juergen Nickelsen

min, max

parent fc914b17
;; fundamental predefined Lisp functions
;(debug t)
(defun max (&rest numargs)
"return the biggest of all (numeric) arguments"
(if (null (cdr numargs))
(car numargs)
(let ((a (car numargs))
(b (apply #'max (cdr numargs))))
(if (< a b)
b
a))))
(defun min (&rest numargs)
"return the smallest of all (numeric) arguments"
(if (null (cdr numargs))
(car numargs)
(let ((a (car numargs))
(b (apply #'min (cdr numargs))))
(if (< a b)
a
b))))
(defun apropos (match)
(sort (filter #'(lambda (sym) (re-match match (symbol-name sym)))
(symbols))
......
......@@ -6,7 +6,9 @@
* more of alists
* min, max; floor ceiling, round
* floor, ceiling, round
+ min, max
+ "isqrt", "return the integer square root of numeric ARG"
......
(testcmp "max 1" '(max) nil)
(testcmp "max 2" '(max 3) 3)
(testcmp "max 3" '(max 3 4 5 2 54 6 9 3 5 7) 54)
(testcmp "max 4" '(max 3 -4 5 -2 54 -6 9 -3 5 -7) 54)
(testcmp "min 1" '(min) nil)
(testcmp "min 2" '(min 3) 3)
(testcmp "min 3" '(min 3 4 5 2 54 6 9 3 5 7) 2)
(testcmp "min 4" '(min 3 -4 5 -2 54 -6 9 -3 5 -7) -7)
(testcmp "min 5" '(min 4 2 4 2 4 2 7 1 19) 1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment