CS61A_sp03_mt1

CS61A_sp03_mt1 - CS 61A, Midterm #1, Spring 2003 CS61A,...

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

View Full Document Right Arrow Icon
Midterm #1 Professor Brian Harvey Question 1 (7 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. (word (first 'happy) (last '(we are))) (((lambda (a b) b) + *) 4 5) ((first '(+ *)) 4 5) (every last '(blackboards eat chalk)) (every member? '(t e the)) (keep (< 6) '(2 8 1 30)) butfirst Question 2 (8 points): Write the procedure powers that behaves as shown here: > (powers 4) (1 2 4 3 9 27 4 16 64 256) (The underlining isn't part of the actual result; it's just there to help you understand the result.) Powers takes a positive integer argument n. It returns a sentence containing, for every k from 1 to n, all the powers of k up to k^k. So the result above is (1^1 2^1 2^2 3^1 3^2 3^3 4^1 4^2 4^3 4^4) Hint: Use a helper that generates the powers of a single value of k. CS 61A, Midterm #1, Spring 2003
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 / 4

CS61A_sp03_mt1 - CS 61A, Midterm #1, Spring 2003 CS61A,...

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