QUIZ #1 SOLUTIONS 1. min One way: (define (min sent) (cond ((empty? (bf sent)) (first sent) ) ((< (first sent) (first (bf sent))) (min (se (first sent) (bf (bf sent)))) ) (else (min (bf sent))) )) That works, but I think that isn't as clear as: (define (min sent) (define (min-helper sent curmin) (cond ((empty? sent) curmin) ((< (first sent) curmin) (min-helper (bf sent) (first sent)) ) (else (min-helper (bf sent) curmin) ))) (min-helper (bf sent) (first sent)) ) Or, a slightly briefer version of the above: (define (min sent) (define (min-helper sent curmin) (if (empty? sent) curmin (min-helper (bf sent) (if (< (first sent) curmin) (first sent) curmin) ))) (min-helper (bf sent) (first sent)) ) 2. Given the following: (define (foo x) (+ x 1)) (define (bar x) (- x 1)) (define (baz x) (let ((foo (lambda (x) (* x 2))) (bar foo)) (foo (bar x)) )) What does the following produce? (foo 10) returns 11 (bar 10) returns 9 (baz 10) returns 22 If you do not understand why (baz 10) is 22, review the first problem from Lab 2b. See also: http://www.csua.berkeley.edu/~jameslin/cs61a/week02.shtml