projects
/
jscl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ff12f0b
)
Use DOLIST instead of WHILE
author
Owen Rodley
<Strigoides@gmail.com>
Sat, 18 May 2013 13:10:48 +0000
(
01:10
+1200)
committer
Owen Rodley
<Strigoides@gmail.com>
Sun, 19 May 2013 23:06:26 +0000
(11:06 +1200)
src/numbers.lisp
patch
|
blob
|
history
diff --git
a/src/numbers.lisp
b/src/numbers.lisp
index
24882b7
..
342c12d
100644
(file)
--- 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)
;; 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))
(return-from ,operator nil)))
t))
@@
-36,11
+35,8
@@
(defun oddp (x) (not (evenp x)))
(flet ((%max-min (x xs func)
(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 #'<)))
x))
(defun max (x &rest xs) (%max-min x xs #'>))
(defun min (x &rest xs) (%max-min x xs #'<)))