Skip to content

Tag Archives: Scheme

SICP习题解答:第二章(上)

?View Code SCHEME;; 2.1 (define (make-rat n d) (if (< d 0) (make-rat (- n) (- d)) (cons n d)))   ;; 2.2 (define (make-point x y) (cons x y)) (define (x-point p) (car p)) (define (y-point p) (cdr p)) (define (make-segment start end) (cons start end)) (define (start-segment s) (car s)) (define (end-segment s) [...]

SICP习题解答:第一章(下)

?View Code SCHEME;; 1.29 (define (simpson-integral f a b n) (define (coefficient i) (cond ((or (= i 0) (= i n)) 1) ((even? i) 2) (else 4))) (let ((h (/ (- b a)n ))) (* (/ h 3) (sum (lambda (i) (* (f (+ a (* i h))) (coefficient i))) 0 (lambda (i) (+ i [...]

SICP习题解答:第一章(上)

?View Code SCHEME;; 1.1-2 略   ;; 1.3 (define (greater-two a b c) (- (+ a b c) (min a b c))) ; 或 (define (greater-two a b c) (cond ((and (> b a) (> c a)) (+ b c)) ((and (> a b) (> c b)) (+ a c)) (else (+ a b))))   [...]