(wat-aro)

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

SICP 問題 2.11

(define (div-interval x y) (let *1 (upx (upper-bound x)) (lowy (lower-bound y)) (upy (upper-bound y))) (cond *2 ( upx upy) ( lowx lowy)) (if (< ( lowx upy) ( upx lowy)) ( lowx upy) ( upx lowy)))))))))

*1:lowx (lower-bound x

*2:> lowx 0) ;;xは正 (cond ((> lowy 0) ;;yは正 (make-interval ( lowx lowy) ( upx upy))) ((< upy 0) ;;yは負 (make-interval ( upx upy) ( lowx lowy))) (else ;;yは0を跨ぐ (make-interval ( upx lowy) ( upx upy))))) ((< upx 0) ;;xは負 (cond ((> lowy 0) ;;yは正 (make-interval ( upx upy) ( lowx lowy))) ((< upy 0) ;;yは負 (make-interval ( lowx lowy) ( upx upy))) (else ;;yは0を跨ぐ (maek-interval ( upx upy) ( upx lowy))))) (else ;;xは0を跨ぐ (cond ((> lowy 0) ;;yは正 (make-interval ( lowx upy) ( upx upy))) ((< upy 0) ;;yは負 (make-interval ( upx upy) ( lowx upy))) (else ;;yは0を跨ぐ (make-interval (if (< ( lowx loxy) ( upx upy