Question:
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, using strate the process generated by each procedure in evaluating (+ 4 5 ).
Are these processes iterative or recursive?
Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------------
The first function:
INC (+ (Dec A) B ),After recursive calling, you also need to return to the original function for Inc computing. Therefore, it is a recursive process
The second function:
Tail recursion is an iterative process
Exercise 1.9