Now let's use this function to describe the floor:
  (defun describe-floor (loc objs obj-loc)
    (apply #'append (mapcar (lambda (x)
                              `(you see a ,x on the floor -))
                            (remove-if-not (lambda (x)
                                             (is-at x loc obj-loc))
                                           objs))))
This function has a couple of new things: First of all, it has anonymous functions (lambda is just a fancy word for this). That first lambda form is just the same as defining a helper function (defun blabla (x) `(you see a ,x on the floor.)) and then sending #'blabla to the mapcar function. The remove-if-not function removes any objects from the list that are not at the current location before passing the list on to mapcar to build pretty sentences. Let's try this new function:
  (describe-floor 'living-room objects object-locations)
  ==> (you see a whiskey-bottle on the floor - you see a bucket 
       on the floor -)
Now we can tie all these descriptor functions into a single, easy command called look that uses the global variables (therefore this function is not in the Functional Programming style) to feed all the descriptor functions and describes everything:
  (defun look ()
    (append (describe-location location map)
            (describe-paths location map)
            (describe-floor location objects object-locations)))
<< begin < previous - next > end >>