很显然,第一个是递归的,第二个是迭代的。
(+ 4 5)
(if (= 4 0) 5 (inc (+ (dec 4) 5)))
(inc (+ 3 5))
(inc (if (= 3 0) 5 (inc (+ 2 5))))
(inc (inc (if (= 2 0) 5 (inc (+ 1 5)))))
(inc (inc (inc (if (= 1 0) 5 (inc (+ 0 5))))))
(inc (inc (inc (inc (if (= 0 0) 5 (inc (+ (dec 0) 5)))))))
(inc (inc (inc (inc 5))))
(inc (inc (inc 6)))
(inc (inc 7))
(inc 8)
9
(+ 4 5)
(if (= 4 0) 5 (+ 3 6))
(if (= 3 0) 6 (+ 2 7))
(if (= 2 0) 7 (+ 1 8))
(if (= 1 0) 8 (+ 0 9))
(if (= 0 0) 9 (+ (dec 0) (inc 9)))
9