SICP 연습문제 1.9 풀이

Universal Machine/SICP | 2008/12/18 21:47 | The Doctor
이 문서는 Structure and Interpretation of Computer, by Abelson, Sussman, and Sussman의 라이센스 이용허가규약 저작자표시-비영리에 따라 제작된 문서입니다. 

혼자 공부하면서 풀어본 것입니다. 그런만큼 틀린게 꽤 많을 것입니다. 문제 있는 부분은 알려주시면 고맙겠습니다.


Exercise 1.9.  Each of the following two procedures defines a method for adding two positive integers in terms of the procedures inc, which increments its argument by 1, and dec, which decrements its argument by 1.

(define (+ a b)
  (if (= a 0)
      b
      (inc (+ (dec a) b))))

(define (+ a b)
  (if (= a 0)
      b
      (+ (dec a) (inc b))))

Using the substitution model, illustrate the process generated by each procedure in evaluating (+ 4 5). Are these processes iterative or recursive?





펼쳐두기..

이전 1 ... 4 5 6 7 8 9 10 11 12 ... 16 다음