-
-
Save gvinter/1034943 to your computer and use it in GitHub Desktop.
SICP Exercise 2.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 2.2 | |
;; SICP Exercise 2.2 | |
;; takes x and y coordinates to create a point | |
(define (make-point x y) | |
(cons x y)) | |
(define (make-segment x1 y1 x2 y2) | |
;; needs implementation | |
(let | |
(= start-segment (make-point x1 y1) | |
(= end-segment (make-point x2 y2)) | |
) | |
;; a line is define by two points, or segments. | |
(define (start-segment line) | |
;;completed for you: | |
(car line) | |
) | |
(define (end-segment line) | |
;; code goes here | |
(car line) ;;??????? | |
) | |
;; What is a begining or end segment? they are a point which is | |
;; represented as a cons. So we need: | |
(define (x-point p) | |
(car p)) | |
(define (y-point p) | |
(cdr p)) | |
) | |
;; this should be taking a single line segment as an argument | |
(define (midpoint-segment segment) | |
;;hint: find the midpoint-x position | |
;;hint: find the midpoint-y position | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment