我正在阅读SICP,并参考其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))))))
用elisp重写
(defun 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: Symbol’s value as variable is void: else
因此请参阅elisp的控制结构,在各种替代方法中都将丢失。
您能否提供提示以cond
和else
定义该功能>
我正在阅读SICP并参考其练习1.10。以下过程将计算一个称为Ackermann函数的数学函数。 (定义(A x y)(cond((= y 0)0)((= x 0)(* 2 y))...
在Emacs Lisp中,您使用t
而不是else
。在这种情况下,Language Reference