From 2dc76e1085326e4b908ea7b8a1fb1fdb9ba3cc1a Mon Sep 17 00:00:00 2001 From: Owen Rodley Date: Sun, 19 May 2013 01:10:48 +1200 Subject: [PATCH] Use DOLIST instead of WHILE --- src/numbers.lisp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/numbers.lisp b/src/numbers.lisp index 24882b7..342c12d 100644 --- a/src/numbers.lisp +++ b/src/numbers.lisp @@ -18,10 +18,9 @@ ;; TODO: Use MACROLET when it exists (defmacro defcomparison (operator) `(defun ,operator (x &rest args) - (while (not (null args)) - (if (,operator x (car args)) - (setq x (car args) - args (cdr args)) + (dolist (y args) + (if (,operator x y) + (setq x (car args)) (return-from ,operator nil))) t)) @@ -36,11 +35,8 @@ (defun oddp (x) (not (evenp x))) (flet ((%max-min (x xs func) - (while (not (null xs)) - (setq x (if (funcall func x (car xs)) - x - (car xs)) - xs (cdr xs))) + (dolist (y xs) + (setq x (if (funcall func x (car xs)) x y))) x)) (defun max (x &rest xs) (%max-min x xs #'>)) (defun min (x &rest xs) (%max-min x xs #'<))) -- 1.7.10.4