This preview shows page 1. Sign up to view the full content.
Unformatted text preview: The book uses pairs to represent many different abstract data types: rational numbers (numerator and denominator), complex numbers (real and imaginary parts), points ( x and y coordinates), intervals (low and high bounds), and line segments (two endpoints). Notice that in the case of line segments we think of the representation as one pair containing two points, not as three pairs containing four numbers. (Thats what it means to respect a data abstraction.) Note: Whats the difference between these two: (define (make-rat num den) (cons num den)) (define make-rat cons) They are both equally good ways to implement a constructor for an abstract data type. The second way has a slight speed advantage (one fewer function call) but the first way has a debugging advantage because you can trace make-rat without tracing all invocations of cons . Data aggregation doesnt have to be primitive....
View Full Document
- Spring '10