Exercise 1.10: The following procedure computes
a mathematical function called Ackermann’s function.
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
What are the values of the following expressions?
(A 1 10)
(A 2 4)
(A 3 3)
Consider the following procedures, where A is the procedure
defined above:
(define (f n) (A 0 n))
(define (g n) (A 1 n))
(define (h n) (A 2 n))
(define (k n) (* 5 n n))
Give concise mathematical definitions for the functions computed by the
procedures f, g, and h for positive integer values of
n. For example, (k n) computes 5
n
2.
练习 1.10:下面的过程计算一个称为 Ackermann 函数的数学函数。
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1))))))
下面各表达式的值分别是什么?
(A 1 10)
(A 2 4)
(A 3 3)
考虑下面几个过程,其中 A 就是上面定义的过程:
(define (f n) (A 0 n))
(define (g n) (A 1 n))
(define (h n) (A 2 n))
(define (k n) (* 5 n n))
对正整数 n,给出过程 f、g 和 h 所计算函数的简洁数学定义。例如,(k n) 计算的是 5n²。
(define (A x y)
(cond ((= y 0) 0)
((= x 0) (* 2 y))
((= y 1) 2)
(else (A (- x 1)
(A x (- y 1)))))) (A 1 10)
(A 2 4)
(A 3 3) (define (f n) (A 0 n))
(define (g n) (A 1 n))
(define (h n) (A 2 n))
(define (k n) (* 5 n n))