program. 算术简化的局部 rewrite 规则[lp-rewrite]

(define (rewrite operation left right)
   (cond
     ((and (integer? left) (integer? right))
      ((if (eq? operation '+) + *) left right))
     ((and (eq? operation '+) (equal? left 0)) right)
     ((and (eq? operation '+) (equal? right 0)) left)
     ((and (eq? operation '*) (equal? left 1)) right)
     ((and (eq? operation '*) (equal? right 1)) left)
     (else (list operation left right))))