SICP問題2.3
周囲の長さを求める手続き [premieter]
(define (premieter rect) (+ (* (width rect) 2) (* (height rect) 2)))
面積を求める手続き [area]
(define (area rect) (* (width rect) (height rect)))
[rectangle] その1 width, height
(define (make-rectangle w h) (cons w h)) (define (width rect) (car rect)) (define (height rect) (cdr rect))
[rectangle] その2 左下と右上の点
(define (make-rectanle lbp rtp) (cons lbp rtp)) (define (width rect) (abs (- (x-point (car rect)) (x-point (cdr rect))))) (define (height rect) (abs (- (y-point (cdr rect)) (y-point (car rect)))))
他の方の回答見てると、四つの頂点の座標からの実装とかの方が良いのかな?