Skip to content

Instantly share code, notes, and snippets.

@gvinter
Forked from klandergren/sicp_2.2.scm
Created June 20, 2011 00:23
Show Gist options
  • Save gvinter/1034943 to your computer and use it in GitHub Desktop.
Save gvinter/1034943 to your computer and use it in GitHub Desktop.
SICP Exercise 2.2
;; 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