cs61a_fa07_mt2

cs61a_fa07_mt2 - CS 61A Fall 2007 Midterm 2 1. What will...

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

View Full Document Right Arrow Icon
CS 61A Fall 2007 Midterm 2 1. What will Scheme print in response to the following expressions? If an expression produces an error message, you may just write “error”; you don’t have to provide the exact text of the message. Also, draw a box and pointer diagram for the value produced by each expression . > (append (cons (list 1 2) (list 2 3)) '(5 6)) > (let ((y (list '(1) 2 3))) (cons '(7 . 8) (cdr y))) 2. Draw a box and pointer diagram for the following list. (3 (9 (2 7) 8) ()) - ----------- -- 3. We’re going to make a new ADT called a hider. A hider provides procedures for encoding and decoding a value, along with a description. (define (make-hider description encoder decoder) (list description (cons encoder decoder))) (a) Write selectors hider-description, encoder, and decoder. Given a hider, they should return the appropriate value. (define (hider-description hider) _________________________________) (define (encoder hider) _________________________________) (define (decoder hider)
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.

Page1 / 3

cs61a_fa07_mt2 - CS 61A Fall 2007 Midterm 2 1. What will...

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