Function: math-beforep
math-beforep is an autoloaded and byte-compiled function defined in
calc-alg.el.gz.
Signature
(math-beforep A B)
Source Code
;; Defined in /usr/src/emacs/lisp/calc/calc-alg.el.gz
;;; True if A comes before B in a canonical ordering of expressions. [P X X]
(defun math-beforep (a b) ; [Public]
(cond ((and (Math-realp a) (Math-realp b))
(let ((comp (math-compare a b)))
(or (eq comp -1)
(and (eq comp 0)
(not (equal a b))
(> (length (memq (car-safe a)
'(nil frac float)))
(length (memq (car-safe b)
'(nil frac float))))))))
((equal b '(neg (var inf var-inf))) nil)
((equal a '(neg (var inf var-inf))) t)
((equal a '(var inf var-inf)) nil)
((equal b '(var inf var-inf)) t)
((Math-realp a)
(if (and (eq (car-safe b) 'intv) (math-intv-constp b))
(if (or (math-beforep a (nth 2 b)) (Math-equal a (nth 2 b)))
t
nil)
t))
((Math-realp b)
(if (and (eq (car-safe a) 'intv) (math-intv-constp a))
(if (math-beforep (nth 2 a) b)
t
nil)
nil))
((and (eq (car a) 'intv) (eq (car b) 'intv)
(math-intv-constp a) (math-intv-constp b))
(let ((comp (math-compare (nth 2 a) (nth 2 b))))
(cond ((eq comp -1) t)
((eq comp 1) nil)
((and (memq (nth 1 a) '(2 3)) (memq (nth 1 b) '(0 1))) t)
((and (memq (nth 1 a) '(0 1)) (memq (nth 1 b) '(2 3))) nil)
((eq (setq comp (math-compare (nth 3 a) (nth 3 b))) -1) t)
((eq comp 1) nil)
((and (memq (nth 1 a) '(0 2)) (memq (nth 1 b) '(1 3))) t)
(t nil))))
((not (eq (not (Math-objectp a)) (not (Math-objectp b))))
(Math-objectp a))
((eq (car a) 'var)
(if (eq (car b) 'var)
(string-lessp (nth 1 a) (nth 1 b))
(not (Math-numberp b))))
((eq (car b) 'var) (Math-numberp a))
((eq (car a) (car b))
(while (and (setq a (cdr a) b (cdr b)) a
(equal (car a) (car b))))
(and b
(or (null a)
(math-beforep (car a) (car b)))))
(t (string-lessp (car a) (car b)))))