CS61A_sp92_mt1

CS61A_sp92_mt1 - CS61A: Midterm #1-Spring 1992 CS61A,...

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

View Full Document Right Arrow Icon
CS61A, Spring 1992 Midterm #1 Question 1 (4 points): What will Scheme print in response to the following expressions? Assume that they are typed in sequence, so definitions affect later interactions. If an expression produces an error message, you may just say ``error''; you don't have to provide the exact text of the message. (* (+ 2 3) (- 7 (* 5 0)))) (if (+ 2 3) (+ 4 5) (+ 6 7)) (define six 6) (let ((- +) (ringo six)) (- six ringo)) (- 6 4) (first (butlast (last (butlast '(the long and winding road))))) (+ (bl 472) (first 38)) (lambda (a b) (word b (first a))) ((lambda (d c) (word (last c) d)) 'here 'not) Question 2 (5 points): Write a procedure add-numbers that takes a sentence as its argument. Some of the words in the argument sentence might be numbers. The procedure should return the sum of those numbers. For example: > (add-numbers '(8 days 1 week)) 9 > (add-numbers '(76 trombones, 4 calling birds, and 2 turtle doves)) 82 > (add-numbers '(all you need is love)) 0 You may use the primitive predicate
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 / 2

CS61A_sp92_mt1 - CS61A: Midterm #1-Spring 1992 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