Chapter 2, Building Abstractions with Data

Section - 2.2 - Hierarchical Data and the Closure Property

Exercise 2.48


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#lang sicp

(#%require sicp-pict)

(define (make-segment sg1 sg2)
   (cons sg1 sg2)
)

(define (start-segment sg)
   (car sg)
)

(define (end-segment sg)
   (cdr sg)
)

Output/Test:

1
2
3
4
5
6
> (define sgmnt (make-segment (make-vect 0 0) (make-vect 1 1)))
> (start-segment sgmnt)
(mcons 0 0)
> (end-segment sgmnt)
(mcons 1 1)
>