Homework: Week 2
1. Exercises 1.31(a), 1.32(a), 1.33, 1.40, 1.41, 1.43, 1.46
I completed these when reading and taking notes on the chapter.
2. A generalized form for a manipulation of list data
(define (square n) (* n n))
(define (every func sent)
(if (equal? sent '())
'()
(se (func (first sent)) (every func (butfirst sent)))))
(every square '(1 2 3 4))
(every first '(nowhere man))
3. Define fact the factorial procedure in terms of only lambda
; Extra for experts
; fact without any way to define global names
(define (fact n)
(if (= 0 n)
1
(* n (fact (- n 1)))))
(fact 5)
((lambda (f n)
(f f n)) (lambda (f x)
(if (= 0 x)
1
(* x (f f (- x 1))))) 5)