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. (That’s what it means to respect a data abstraction.) Note: What’s 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 doesn’t have to be primitive....
View Full Document
- Spring '10
- Object-Oriented Programming, Type system, Type theory, cons num den