For this homework you are to trace through the evolution of the following Scheme programs. If the program would go into an infinite loop, then trace it for a while and then state that it loops.
(define (c t) (+ 32 (/ (* t 9) 5))) (c 100) (c 37)
(define (s x) (* x x)) (define (t x y) (+ 1 (* x y))) (s (t 3 (s 2)))
%
is the remainder
operator, so (% 53 7)
is 4 and 53/7=7 with a remainder of 4.
(define (hmmm a b) (if (= a 0) b (hmmm b (% a b)))) (hmmm 42 150)
(define (ahha x n p) (if (= n 0) p (ahha x (- n 1) (* x p)))) (ahha 2 10 1)
(define (f x y z) (if (= x 0) z (f (- x 1) y (* z y)))) (f 8 2 1) (f -3 2 1)
Note: if your responses were given by a program that I had access to, I could easily create one of these problems that you could not solve by creating a problem that involved your code! As you are human, that trick does not apply!