我需要一些帮助,当我自己在解释器中输入值时,我的代码没有返回好的答案。这是我的代码:
(defun compromis()
(flet ((prompt (string)
(format t "~&~a: " string)
(read nil 'eof nil)))
(print "Enter values :")
(let ((E (prompt "tddv_estime"))
(W (prompt "tddv_worst"))
(C (prompt "gisement_courant"))
(M (prompt "gisement_max"))
(m (prompt "gisement_min")))
(if (> E W)
(if (> C m)
(print "Decrement")
(print "Error")))
(if (< E W)
(if (< C M)
(print "Increment")
(print "Nothing"))))))
当我应该用 E=8
、W=16
、C=2
、 读取“增量”时Max=8
和 Min=1
,我的 "Nothing"
显示了两次...
最佳答案
您会看到“Nothing”
两次,因为
print
都打印并且
返回它的参数,并且,因为它是函数中的最后一种形式
compromis
,它返回print
返回的值。
由于您正在评估 REPL 中的代码(Read-Eval-Print 循环),
您会看到打印输出和返回值。
关于lisp - GNU CLISP 中的 if 条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50350007/