SICP notes + exercises

Skipped 1.1 for reason of simplicity;
Skipped 1.4 for reason of syntax incompatibility with a modern IDE.

 

Ex 1.2:

Translate the following expression into prefix form

\(\frac{\left(2-\left(3-\left(6+\frac{1}{3}\right)\right)\right)+\frac{1}{2}+5}{3 (6-2) (2-7)}\)

 

solution:

(/ (+ 5 (+ (/ 1 2) (- 2 (- 3 (+ 6 (/ 1 3)))))) (* 3 (* (- 6 2) (- 2 7))))

 

ans =

\(-\frac{13}{73}\)

 

Ex 1.3:

Through Ex1-8 (a problem set of building/improving cube root function)

ex1-9:

 

(let a 4 b 5)

in procedure ex-1.9a
(+ 4 5)
“a != 0″
=(inc (+ (dec 4) 5))
=(inc (+ 3 5))
“a !=0″
=(inc (inc (+ (dec 3) 5)))

using itself as a value to a procedure resided inside itself, recursive call found!

in the next procedure
(+ 4 5)
=(+ (dec 4) (inc 5))
=(+ 3 6)

returned a simple (atomic) value for next input, iteration found.