I'm receiving the error variable MAP has no value
in my Common Lisp code (I am using the clisp shell in the Ubuntu terminal). My code looks like this (*map*
is just an association list, so you can skip over it):
(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*)
(I'm following the liserpati tutorial, for those wondering about any oddities I might be committing)
If change walk-to to
(defspel walk-to (direction room)
`(walk-direction ',direction ',room *map*))
then everything goes perfectly well. However, this breaks the beautiful convention of functional programming which I would like to keep as intact as possible-- not to mention the fact that I still have no idea why my code doesn't work.
<code>
tags, etc. Just paste in your plain code, highlight it, and press the{}
toolbar button, which will tab it over into a code block. – ooga