1.1
10
;Value: 10
(+ 5 3 4)
;Value: 12
(- 9 1)
;Value: 8
(/ 6 2)
;Value: 3
(+ ( 2 4) (- 4 6))
;Value: 6
(define a 3)
;Value: a
(define b (+ a 1))
;Value: b
(+ a b ( a b))
;Value: 19
(= a b)
;Value: #f
(if (and (> b a) ( b a) b a))
;Value: 6
(* (cond ((> a b) a)
((< a b) b)
(else -1))
(+ a 1))
;Value: 16
1.4
The operator can change depending on if b is less then or greater then 0. If greater then, it adds a to b. If less then zero it subtracts b from a, giving us a + |b|.
1.5
Normal Order will cause and infinite recursive loop, where applicative-order will return 0. The reason is because p is a recursive call to itself. So if we try and fully expand (test 0 (p)) we will never finish because (p) will always be expanded into (p). However, if we are in applicative-order, then (= x 0) is evaluated first and the if statment can be checked without trying to expand (p).
This appears to be completely wrong upon testing :(
Hmm, I'll try and think about this more tomorrow...
1.6
Both of the parameters in her new-if method will be expanded, this causes a problem with recessive calls, if is special because the else doesn't need to be exceeded unless the first condition fails.
1.7
This test is not very good for small numbers because say the sort of .00000001 is .0001, so the check will stop as soon as it get's below .001.
For very large numbers there will be limit to the precision that a number can be expressed in. If the number is too large it will not expressed down to .001, so the calcuation will never be "good enough"
A better example wold be something like this to to normalize the comparison before checking how close it is.
(define (good-enough2? guess x)
(< (abs (/ (- (square guess) x) 2) 0.001))