;; CS 3520 ;; Fall 2001 ;; HW 1 example solution 1.1 * (1 + (2 - 3)) -> (1 + -1) -> 0 * f(x) = (x + x) f((4 + 5)) -> f(x) = (x + x) f(9) -> f(x) = (x + x) (9 + 9) -> f(x) = (x + x) 18 * g(y) = (y - 1) h(z) = (z + g(z)) h(17) -> g(y) = (y - 1) h(z) = (z + g(z)) (17 + g(17)) -> g(y) = (y - 1) h(z) = (z + g(z)) (17 + (17 - 1)) -> g(y) = (y - 1) h(z) = (z + g(z)) (17 + 16) -> g(y) = (y - 1) h(z) = (z + g(z)) 33 1.2 * + : not a program * (1 + 2) : a program 1 in 2 in ----------- ----------- 1 in 2 in ------------------------- (1 + 2) in ------------------- (1 + 2) in * 1 + 2 : not a program (missing parens) * f(x) = f(x) f(x) : a program x in ----------- f in x in x in ---------------------- ----------- f in x in f(x) in f in x in -------------------------------------------- ---------------------- f(x) = f(x) in f(x) in ---------------------------------------------------------------------- f(x) = f(x) f(x) in * f(x) = 1 (1 + 1) g(x) = 2 (2 + 2) : not a program (extra expression between definitions) * f(x) = 1 g(x) = 1 (1 - 1) : a program 1 in 1 in 1 in 1 in ----------- ----------- ----------- ----------- f in x in 1 in g in x in 1 in 1 in 1 in --------------------------------- --------------------------------- ----------------------- f(x) = 1 in g(x) = 1 in (1 - 1) in --------------------------------------------------------------------------------------------- f(x) = 1 g(x) = 1 (1 - 1) in