Computer Science 61A - Spring 2001 - Harvey - Midterm 1

Computer Science 61A - Spring 2001 - Harvey - Midterm 1 -...

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

View Full Document Right Arrow Icon
CS61A, Midterm #1, Spring 2001 CS61A, Spring 2001 Midterm #1 Professor Brian Harvey Question 1 (5 points): 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. If the value of an expression is a procedure, just write "procedure"; you don't have to show the form in which Scheme prints procedures. (butfirst (butlast (se '(this) 'is '(easy) ))) (car ((lambda (lst) (cdr lst)) '((1 2) (3 4)) ) ) (let ((rotate (lambda (a b c) (if (number? a) a (b c 2 3))))) (rotate rotate rotate 1)) (if (equal? '2 2) + -) (map butfirst '((she loves you) (help!) (penny lane))) Question 2 (6 points): The following program takes two arguments: a number and a file:///C|/Documents%20and%20Settings/Jason%20Raft. ..20Spring%202001%20-%20Harvey%20-%20Midterm%201.htm (1 of 6)1/27/2007 6:29:49 PM
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS61A, Midterm #1, Spring 2001 list of sentences. It returns a sentence containing the n th word (counting from zero) from each of the sentences in the argument list: >(every-nth 2 '((a b c d) (e f g h))) (c g) Fill in the blanks, respecting the data abstraction! (define (every-nth num list-of-sents) (define (nth num sent) (if (= num 0) ( __________ sent) (nth (- num 1) ( __________ sent)))) (if ( __________ list-of-sents) '() ( __________ (nth num ( __________ list-of-sents)) (every-nth num ( __________ list-of-sents)) Question 3 (6 points):
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

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

Page1 / 6

Computer Science 61A - Spring 2001 - Harvey - Midterm 1 -...

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

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