Picking Up Objects

Next, let’s create a command to pick up objects in our world. To do so, we modify the variable *object-locations* that we’re using to track the location of objects:

(defun pickup (object)
  (cond ((member object
                 (objects-at *location* *objects* *object-locations*))
         (push (list object 'body) *object-locations*)
           `(you are now carrying the ,object))
          (t '(you cannot get that.))))

The pickup function uses the member function to see if ...

Get Land of Lisp now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.