(wat-aro)

無職から有職者にランクアップしました

SICP 問題 2.79

;; scheme-numberパッケージに追加
(put 'equ? '(scheme-number scheme-number)
       (lambda (x y) (tag (= x y))))

;; rationalパッケージに追加
(put 'equ? '(rational rational)
       (lambda (x y) (and (= (numer x) (numer y))
                          (= (denom x) (denom y)))))
;; complexパッケージに追加
(put 'equ '(complex complex)
     (lambda (x y) (and (= (real-part x) (real-part y))
                        (= (imag-part x) (imag-part y)))))


(define (equ? x y) (apply-generic 'equ? x y))