(in-package :util) (defun compare (a b) (cond ((and (consp a) (atom b)) (setf a (car a))) ((and (atom a) (consp b)) (setf b (car b)))) (cond ((eql a b) 0) ((and (not a) b) -1) ((and a (not b)) 1) ((and (integerp a) (integerp b)) (- a b)) ((and (typep a '(or string character symbol)) (typep b '(or string character symbol))) (cond ((string-lessp a b) -1) ((string-equal a b) 0) ((string-greaterp a b) 1))) ((and (consp a) (consp b)) (let ((comp (compare (car a) (car b)))) (if (zerop comp) (compare (cdr a) (cdr b)) comp))) (t (compare-objects a b)))) (defmethod compare-objects ((a t) (b t)) 0) (defun lookup= (a b) (zerop (compare a b))) (defun lookup/= (a b) (not (zerop (compare a b)))) (defun lookup< (a b) (< (compare a b) 0)) (defun lookup<= (a b) (<= (compare a b) 0)) (defun lookup> (a b) (> (compare a b) 0)) (defun lookup>= (a b) (>= (compare a b) 0))