首页 > 代码库 > SICP_2.12-2.16(部分习题)
SICP_2.12-2.16(部分习题)
1 (require "sicp_2.7-2.11.rkt") 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2.12 3 (define (make-center-width c w) 4 (make-interval (- c w) (+ c w))) 5 6 (define (make-center-percent c p) 7 (let ((width (* c (/ p 100)))) 8 (make-interval (- c width) (+ c width)))) 9 10 (define (center i) 11 (/ (+ (lower-bound i) (upper-bound i)) 2)) 12 13 (define (percent i) 14 (* 100 (abs (/ (width-interval i) (center i))))) 15 16 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2.14 17 (define (par1 r1 r2) 18 (div-interval (mul-interval r1 r2) 19 (add-interval r1 r2))) 20 21 (define (par2 r1 r2) 22 (let ((one (make-interval 1 1))) 23 (div-interval one 24 (add-interval (div-interval one r1) 25 (div-interval one r2))))) 26 27 (define inter1 (make-center-percent 2 50)) 28 (define inter2 (make-center-percent 4 50)) 29 (define A (make-center-percent 2 0.0004)) 30 (define B (make-center-percent 4 0.0004)) 31 32 (par1 inter1 inter2) 33 (par2 inter1 inter2) 34 35 (div-interval A B) 36 (div-interval A A)
SICP_2.12-2.16(部分习题)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。