这个常见的lisp代码有什么问题?

时间:2012-01-12 15:36:11

标签: lisp common-lisp

基本上我尝试评估下面的函数,但不断收到以下错误:

 WARNING :
MAINDIA is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
WARNING :
SOUT is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
WARNING :
NORT is neither declared nor bound,
it will be treated as if it were declared SPECIAL.
*** - NIL: variable MAINDIA has no value
The following restarts are available:
ABORT          :R1      Abort debug loop
ABORT          :R2      Abort debug loop
ABORT          :R3      Abort debug loop
ABORT          :R4      Abort debug loop
ABORT          :R5      Abort debug loop
ABORT          :R6      Abort debug loop
ABORT          :R7      Abort debug loop
ABORT          :R8      Abort main loop

当我尝试从互联网上复制并粘贴一个示例时,它可以正常工作,但是当我手动将其键入解释器时,它不起作用。另外,我正在从emacs运行CLISP。

代码:

(defun diagonal-mast (sq)
  (let* ((maindia #x8040201008040201)
         (diag (- (* 8 (logand sq 7))
                  (logand sq 56)))
         (nort (logand (- diag)
                       (ash diag -31)))
         (sout (logand diag (ash (- diag) -31))))
    (ash (ash maindia (- sout))
         nort)))

NOte:我在CLISP 2.48

1 个答案:

答案 0 :(得分:1)

很有可能,你的问题是emacs,而不是代码,因为它在评论者和我的lisps中运行良好。我不再使用emacs,因此以下解决方案可能已被弃用或完全错误,但如果您通过emacs --debug-init启动Emacs并收到错误消息,则会遇到一些设置问题而不是代码问题。好吧,似乎你的lisp实现是问题,而不是你的lisp写作。如果它是某种方式你的lisp实现,只需重建,它应该没问题。如果这是你的设置,我很确定slimedev有一些非常详尽的错误和修复列表。好狩猎。