-
-
Save klandergren/1031999 to your computer and use it in GitHub Desktop.
SICP Exercise 2.2
This file contains hidden or 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 | |
| ) | |
| ;; 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 | |
| ) | |
| ;; 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) | |
| ;;left for you | |
| ) | |
| ;; 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