Skip to content

Instantly share code, notes, and snippets.

@klandergren
Forked from gvinter/gist:1029936
Created June 17, 2011 18:34
Show Gist options
  • Select an option

  • Save klandergren/1031999 to your computer and use it in GitHub Desktop.

Select an option

Save klandergren/1031999 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
)
;; 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