Symbolic Simplification Programs


; Symbolic +, e.g. (s+ 0 'x)
(defun s+ (x y)
  (cond ((numberp x)
          (cond ((numberp y) (+ x y))
                ((zerop x) y)
                (t (list '+ x y))))
        ((and (numberp y)
              (zerop y)) x)
        (t (list '+ x y)) ))

; Symbolic *, e.g. (s* 'x 1)
(defun s* (x y)
  (cond ((numberp x)
          (cond ((numberp y) (* x y))
                ((zerop x) 0)
                ((equal x 1) y)
                (t (list '* x y)) ))
        ((numberp y)
          (cond ((zerop y) 0)
                ((equal y 1) x)
                (t (list '* x y)) ))
        (t (list '* x y)) ))

Contents    Page-10    Prev    Next    Page+10    Index