Loading Fundamental.lisp +20 −0 Original line number Diff line number Diff line ;; 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)) Loading TODO +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading tests/037-minmax.lisp 0 → 100644 +10 −0 Original line number Diff line number Diff line (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) Loading
Fundamental.lisp +20 −0 Original line number Diff line number Diff line ;; 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)) Loading
TODO +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading
tests/037-minmax.lisp 0 → 100644 +10 −0 Original line number Diff line number Diff line (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)