Implement a representation for rectangles in a plane. (Hint: You may want to make use of exercise 2.2 ). In terms of your constructors and selectors, create procedures that compute the perimeter and the area of a given rectangle. Now implement a different representation for rectangles. Can you design your system with suitable abstraction barriers, so that the same perimeter and area procedures will work using either representation?
There are no comments yet.
You must log in to post a comment.Login
(define (make-point x y) (cons x y)) (define start-point (make-point 0 0)) (define rectangle (make-rectangle start-point 2 3)) (check-equal? (rectangle-square rectangle) 6) (check-equal? (rectangle-perimeter rectangle) 10)