{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

notes20 - The book uses pairs to represent many different...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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

{[ snackBarMessage ]}

Ask a homework question - tutors are online