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