I was just solving the book Structure and Interpretation of Computer Programs and have a question concerning exercise 1.10, which, using Ackermann's function defined as
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
determine the value of the expression (A 1 10).
Here's my solution:
(A 1 10)
(A 0 (A 0 9))
(A 0 (18))
36
Now i know the answer is 1024, i got the solution on the internet but what I thought would happen is when x's value would decrement the value of x in (A x (- y 1))
would be the decremented value but it seems it isn't the case. How ? Wouldn't as per the applicative-order it would be true?
Moreover it was the same thing that happened in ex 1.9 when the decremented value was able to call the function.
Thank you in advance.