(defun zerop (x) (= x 0))
(defun plusp (x) (< 0 x))
+(defun signum (x)
+ (if (zerop x) x (/ x (abs x))))
+
- ;; TODO: Use MACROLET when it exists
- (defmacro defcomparison (operator)
- `(defun ,operator (x &rest args)
- (dolist (y args)
- (if (,operator x y)
- (setq x (car args))
- (return-from ,operator nil)))
- t))
-
- (defcomparison >)
- (defcomparison >=)
- (defcomparison =)
- (defcomparison <)
- (defcomparison <=)
- (defcomparison /=)
+ (macrolet ((def (operator)
+ `(defun ,operator (x &rest args)
+ (dolist (y args)
+ (if (,operator x y)
+ (setq x (car args))
+ (return-from ,operator nil)))
+ t)))
+ (def >)
+ (def >=)
+ (def =)
+ (def <)
+ (def <=)
+ (def /=))
(defconstant pi 3.141592653589793)