Practice 2.79
(define (equ? x y)
(apply-generic 'equ? x y))
install-rational-package add
(put 'equ? '(rational rational) (lambda (x y) (and (= (numer x) (numer y)) (= (denom x) (denom y)))))
install-complex-package add
(put 'equ? '(complex complex)
(lambda (x y)
(or (and (eq? (real-part x) (real-part y)) (= (imag-part x) (imag-part y)))
(and (eq? (magnitude x) (magnitude y)) (= (angle x) (angle y))))))
install-scheme-number-package add
(put 'equ? '(scheme-number scheme-number) (lambda (x y) (= x y)))