From 627767534ff91e86ab860df0c519040ce2b43ed9 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Sun, 29 Jun 2014 19:34:31 -0400 Subject: [PATCH] Use segments in Ex2.2 --- 2-1.org | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/2-1.org b/2-1.org index 9642532..23468c6 100644 --- a/2-1.org +++ b/2-1.org @@ -113,11 +113,17 @@ layout: org (define x-point car) (define y-point cdr) - (define (midpoint-segment p1 p2) - (let ((average (lambda (x y) (/ (+ x y) 2)))) - (make-point - (average (x-point p1) (x-point p2)) - (average (y-point p1) (y-point p2))))) + (define make-segment cons) + (define start-segment car) + (define end-segment cdr) + + (define (midpoint-segment segment) + (let ((p1 (start-segment segment)) + (p2 (end-segment segment))) + (let ((average (lambda (x y) (/ (+ x y) 2)))) + (make-point + (average (x-point p1) (x-point p2)) + (average (y-point p1) (y-point p2)))))) #+end_src ** Exercise 2.3: Implement a representation for rectangles in a plane. (Hint: You