Another problem with our describe-location function is
that it doesn't tells us about the paths in and out of the
location to other locations. Let's write a function that
describes these paths:
|
(defun describe-path (path)
`(there is a ,(second path) going ,(first path) from here -))
|
Ok, now this function looks pretty strange: It almost looks
more like a piece of data than a function. Let's try it out
first and figure out how it does what it does later:
|
(describe-path '(west door garden))
|
==> (there is a door going west from here -)
|
So now it's clear: This function takes a list describing a
path (just like we have inside our map variable) and
makes a nice sentence out of it. Now when we look at the
function again, we can see that the function "looks" a lot
like the data it produces: It basically just splices the first
and second item from the path into a declared sentence. How does
it do this? It uses back-quoting!
|
Remember that we've used a quote before to flip the
interpreter from Code mode to Data mode. Well,
by using the back-quote (the quote in the upper left corner of
the keyboard) we can not only flip, but then also
flop back into Code mode by using a comma:
|
|
<< begin
< previous -
next >
end >>
|