Max*_*Max 2 lisp clisp common-lisp
我variable MAP has no value
在Common Lisp代码中收到错误(我在Ubuntu终端中使用clisp shell).我的代码看起来像这样(*map*
只是一个关联列表,所以你可以跳过它):
(setf *map* '((shore (stars cast reflections on the rippling sea.
it fills you with a strong but unplaceable emotion.)
(east forest))
(forest (a roof of treetops blots out the sun. something rustles
behind you.)
(west shore)
(north cliff))
(cliff (you nearly stumble into a long and fatal fall into the
sea far below you. you feel a strange urge to throw
yourself off the ledge. it would probably wisest to
leave this place.)
(south forest))))
(defun walk-direction (direction room map)
(second (assoc direction (cddr (assoc room map)))))
(defmacro defspel (&rest rest) `(defmacro ,@rest))
(defspel walk-to (direction room map)
`(walk-direction ',direction ',room map))
(walk-to east shore *map*)
Run Code Online (Sandbox Code Playgroud)
(我正在关注liserpati教程,对那些想知道我可能犯下的任何奇怪的事情)
如果改变步行到
(defspel walk-to (direction room)
`(walk-direction ',direction ',room *map*))
Run Code Online (Sandbox Code Playgroud)
那一切都很顺利.然而,这打破了函数式编程的美妙习惯,我希望尽可能保持完整 - 更不用说我仍然不知道为什么我的代码不起作用的事实.
之前的定义walk-to
是缺少逗号map
.看一下输出:
(macroexpand-1 '(walk-to east shore *map*))
Run Code Online (Sandbox Code Playgroud)