SICP 2.3 习题答案
程序员文章站
2022-07-14 10:56:07
...
可能书上想让我用2.2的答案,实在不想那么搞。。。
(define (make-point x y) (cons x y)) (define (x-point p) (car p)) (define (y-point p) (cdr p)) (define (make-rect left-top right-bottom) (cons left-top right-bottom)) (define (bottom-left rect) (make-point (x-point (car rect)) (y-point (cdr rect)))) (define (bottom-right rect) (cdr rect)) (define (top-left rect) (car rect)) (define (top-right rect) (make-point (x-point (cdr rect)) (y-point (car rect)))) (define (width-rect rect) (abs (- (x-point (car rect)) (x-point (cdr rect))))) (define (height-rect rect) (abs (- (y-point (car rect)) (y-point (cdr rect))))) (define (perimeter-rect rect) (* 2 (+ (width-rect rect) (height-rect rect)))) (define (area-rect rect) (* (width-rect rect) (height-rect rect)))
上一篇: git remote用法总结
下一篇: SICP 2.7~2.16习题答案