This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS 61A, Fall 2001 Midterm #1 Question #1 (7 points): What will Scheme print in response to the following expressions? If an expression produces an error message or runs forever without producing a result, you may just say "error"; you don't have to provide the exact text of the message. If the value of an expression is a procedure, just say "procedure"; you don't have to show the form in which Scheme prints procedures. (last (se (se '61a 'is) (se 'really 'fun)) ) (keep (lambda (wd) #f) '(a b c d e)) ;KEEP is definied in the lecture notes, p. 128 of the reader ((lambda (a) (lambda (b) (se a b)) 'over)) 'under)) (if (not (lambda () 10)) (/ 1 0) 'scheme) (let ((a 5) (b (+ a 3))) (* a b)) ((lambda (a b) ((if (< b a) + *) b a)) 4 6) (first '(word 'a 'b 'c)) Problem #2 (10 points): Write a procedure named funtion-combiner that takes a list of functions as an argument Function-combiner will return a funtion of one argument that applies the first function to the result of applying the second function to ... applying the last function to the argument. Here are some sample interactions: > (define (square x) (* x x)) > (define (1+ x) (+ x 1)) > (define square-1+ (function-combiner (list square 1+))) > (square-1+ 10) ;;returns (square (1+ 10)) 121 CS 61A, Midterm #1, Fall 2001 CS 61A, Fall 2001 Midterm #1 1 > ((function-combiner (list list first bf bl)) '(first second third fourth))...
View Full Document
- Fall '08
- Computer Programming