Homework 2 Answers Part I 1. a) 72 b) 48 c) 72 d) (72 5 4) 2. 14 3. (define (flatten tree) (cond ((null? tree) '()) ((pair? tree) (append (flatten (car tree)) (flatten (cdr tree)))) (else (list tree)) ) ) Part II 1. (define (fact n) (define (fact-helper product n) (if (= n 0) product (fact-helper (* n product) (- n 1)) ) ) (if (< n 0) (error "Cannot find factorial of a negative number") (fact-helper 1 n) ) ) 2. (define (curry f x) (lambda (y) (f x y))) 3. (define (filter f l) (if (null? l) '() (let ((head (car l)) (tail (filter f (cdr l)))) (if (f head) (cons head tail) tail ) ) ) ) 4. (define (positive-only) (filter (curry < 0)))