Exercise 1.1
10 => 10
(+ 5 3 4) => 12
(- 9 1) => 8
(/ 6 2) => 3
(+ ( 2 4) (- 4 6)) => 6
(define a 3) => a
(define b (+ a 1)) => b
(+ a b ( a b)) => 19
(= a b) => false
(if (and (> b a) ( 4
(cond ((= a 4) 6)
((= b 4) (+ 6 7 a)) => 16(+)
(else 25))
(+ 2 (if (> b a) b a)) => 6
(* (cond ((> a b) a)
(( 16
Exercise 1.2:
(/ (+ 5 t (- 2 (- 3 (+ 6 (/ 1 5))))) 3 (- 6 2) (- 2 7))
Exercise 1.3:
efine (sum-of-squares a b)
(+ (square a) (square b)))
(define (sum-of-squares-of-larger-two a b c)
(cond ((and ( a c)) (sum-of-squares a b))
((and (= b c) (> b a)) (sum-of-squares b c))
((and (= c a) (> c b)) (sum-of-squares c a))
((and (= a b) ( b 0) + -) a b))
(a-plus-abs-b a b) expands to
((if (> b 0) + -) a b) for -ve b => (- a b)
for +ve b => (+ a b)
Exercise 1.5:
??
Exercise 1.6
Infinite loop due to Applicative-order.
Exercise 1.7
For large numbers, The first iteration produces a very large number (will be slow?)
For small numbers invariably good-enough? will return a false +ve due to the tolerance variable.