Hatena::Groupcsnagoya-sicp

yoshihiro503の日記

2009-04-11Exercise 2.2 2.4 2.6

Exercise 2.2

12:34

line segmentの定義 (ポイントフリースタイルで)

(define make-segment cons)
(define start-segment car)
(define end-segment cdr)

同様にpointの定義

(define make-point cons)
(define x-point car)
(define y-point cdr)
(define (pair-app fg) (lambda (xy) (cons ((car fg) (car xy)) ((cdr fg) (cdr xy)))))

(define (av x1) (lambda (x2) (/ (+ x1 x2) 2)))
(define (midpoint-segment sp ep)((pair-app ((pair-app (cons av av)) sp)) ep)