CS61A_fa94_mt2 - CS61A: Midterm #2-Fall 1994 CS61A, Fall...

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

View Full Document Right Arrow Icon
CS61A, Fall 1994 Midterm #2 Question 1 (4 points): What will Scheme print in response to the following expressions? Also, draw a ``box and pointer'' diagram for the result of each expression: (cons (append '(a b) '(c d)) '(e f)) (list (cons 'a 'b) (list 'c 'd) 'e) (caaddr '((a b c d e) (f g h i j) (l m n o p) (q r s t u))) (cons 'a (cdr '(((b))))) Question 2 (5 points): Recall that the definition of a list is that it's either the empty list or a pair whose cdr is a list. This definition says nothing about the elements of the list. For example, (1 2 (3 . 4) (5 . 6) 7) is a list of five elements, even though two of the elements are pairs that aren't lists. We'll define a deep list as a list in which every element is either a deep list or not a pair. Equivalently, a deep list is a structure made of pairs in which the cdr of every pair, including the ones in the elements, is a list. Write the predicate deep-list? that takes any Scheme object as its argument, returning #t if the argument is a deep list.
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 11/23/2010 for the course CS 61A taught by Professor Harvey during the Fall '08 term at University of California, Berkeley.

Page1 / 2

CS61A_fa94_mt2 - CS61A: Midterm #2-Fall 1994 CS61A, Fall...

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