Computer Science 61A - Spring 1995 - Clancy - Midterm 3

Computer Science 61A - Spring 1995 - Clancy - Midterm 3 -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS61A: Midterm #3--Spring 1995 CS61A, Spring 1995 Midterm #3 Question 1 (3 points): What will the Scheme interpreter print in response to each of the following expressions? Also, draw a ``box and pointer'' diagram for the result of each expression. Hint: It'll be a lot easier if you draw the box and pointer diagram first ! (let ((x (list 1 2 3 4))) (set-cdr! x (caddr x)) x) {\prgex% (let ((x (list 1 2 3 4))) (set-car! (cdr x) (cddr x)) x) (let ((x (list 1 (list 2 3) 4))) (set-car! (cadr x) (car x)) x) Question 2 (4 points): Define an object class called password-protect . The purpose of the class is to allow an object to be ``hidden'' so that a password is needed to send it messages. Here's how it works. Suppose we have this class definition: (define-class (counter) (instance-vars (count 0)) (method (next) (set! count (+ count 1)) count)) In order to make a password-protected counter, we want to be able to do this: > (define ppc (instantiate password-protect (instantiate counter) 'exotic))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/17/2009 for the course CS 61A taught by Professor Harvey during the Spring '08 term at University of California, Berkeley.

Page1 / 3

Computer Science 61A - Spring 1995 - Clancy - Midterm 3 -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online