0
我有这样的功能:共LISP - 减法
(defun test (variable)
(cond
((null variable) nil)
((< (- 12 (other-function variable) 3) 0) 1)
(t (- 12 (other-function variable) 3))
)
)
的想法是,如果12的与3的函数的值的减法运算的结果小于0,则返回1,否则,它只会进行减法。 “其他功能”返回一个数字。 当我运行此功能时,lispworks冻结。但是,如果我运行没有第一个条件的功能:
(defun test (variable)
(cond
((null variable) nil)
(t (- 12 (other-function variable) 3))
)
)
它使得减法没有任何问题。 有人可以帮忙吗? 谢谢。
编辑: 我试过这样与设:
(defun test (variable)
(let (x (other-function variable))
(cond
((null variable) nil)
((< (- 12 x 3) 0) 1)
(t (- 12 x 3)))
)
)
,但我仍然得到了同样的问题lispworks至极,它冻结。当我没有以下条件运行:
((< (- 12 x 3) 0) 1)
此功能正常工作。
在我看来,问题在于'other-function'而不是'test'。而不是两次做同样的事情,你可以在'let'中绑定这个值并重用这个变量。 – Sylwester
@Sylwester我会添加我试着用这个问题的方式。感谢你的回答。 – MarB
请发表[mcve]。 – melpomene