Tutorial 3 Followup ------------------- This email may also be accessed through my 6.001 page: http://people.csail.mit.edu/~dalleyg/6.001/index.html 1) Quiz 1 is this Wednesday. Please read the two notes about it on the course website at http://sicp.csail.mit.edu/Spring-2005/. Things to note: place & time, review sessions, notes policy, quizzes from previous terms. 2) Quiz 1 will cover everything that we've covered in class so far, including the material we'll review in next week's tutorial. Everything through higher-order procedures is fair game. 3) Special office hours: I'll be holding special office hours in 32-044F on Monday from 4-5:30pm. Since the LAs are running organized review sessions, my intention is not to duplicate their efforts. I'll be available to answer questions you have, but I will not be coming with a prepared set of topics to cover. 4) Project 2 is out now. 5) View this note with a fixed-width font... In tutorial, we saw two box-and-pointer representations for (cons 1 2): +---+---+ +---+---+ | 1 | 2 | and | | | -+-> 2 +---+---+ +-+-+---+ | v 1 The question boils down to whether Scheme chooses to embed non-pair values directly in the car and cdr parts of a pair or whether it only stores pointers to other values. For our particular implementation of Scheme, it turns out that it depends on the size of the number. Small numbers (ones representable <= 24 bits) are actually stored inside the car and cdr parts while larger numbers are stored via pointers. See the following test code to verify this statement: ;; Test whether a number 2^exp is embedded inside a pair ;; in this implementation of Scheme (define (exp-embeds exp) ; Create the pair with the same logical values in the ; car and cdr parts (define pair (cons (expt 2 exp) (expt 2 exp))) ; Do the two parts refer to the same object. If the ; actual integer value is embedded in the pair, they ; refer to the same objects. If Scheme uses a pointer, ; it must construct a new object for each number, so ; they will not be eq?. (eq? (car pair) (cdr pair))) (exp-embeds 24) ; --> #t for 6.001 Scheme (exp-embeds 25) ; --> #f for 6.001 Scheme Don't worry about being responsible for this note (#5) for test purposes. --Gerald Dalley dalleyg@mit.edu