(objects-at ()) returning NIL in the REPL

Skip to first unread message


Jun 10, 2022, 2:03:52 PMJun 10
to Land of Lisp
I've recently picked up LoL without any previous programming experience. I had an issue at chapter 7 with the graph creation (apparently, the instructions are incorrect, I remember not finding the same commands in the Graphviz documentation), kinda got discouraged and came back again to give it a fresh shot. I started from the beginning and now I have come across an issue I may have had before too, but it could be that I didn't give it much thought.

The objects-at function returns a NIL result regardless of the inputs I use. I can't see what I'm doing wrong here. And to be honest, though, I don't understand how the function actually works yet, I'm kind of just following along, hoping to understand along the way.

It's not as if there is a bad function "definition", I would get a REPL warning about that, telling me to abort mission (on a side note, I haven't figured what those :Rn ABORT etc. mean and how to "use" them).

Any ideas? What might I be doing wrong? Thanks.

Win Treese

Jun 11, 2022, 4:51:38 PMJun 11
to Konstantinos PAPADOPOULOS, land-o...@googlegroups.com
Hi Konstantinos. Welcome to Lisp!

How did you invoke objects-at?

I copied the relevant code from the book

(defparameter *objects* '(whiskey bucket frog chain))

(defparameter *object-locations* '((whiskey living-room)
(bucket living-room)
(chain garden)
(frog garden)))

(defun objects-at (loc objs obj-locs)
(labels ((at-loc-p (obj)
(eq (cadr (assoc obj obj-locs)) loc)))
(remove-if-not #'at-loc-p objs)))

Note: in general I recommend typing in code yourself when you are learning new stuff, and you may be doing that, but I wanted to make sure I got it right quickly and just copied it.

Then I ran:

(objects-at 'garden *objects* *object-locations*)

So, two questions:

1. How are you invoking objects-at?
2. Did you double-check all the code?

We can also talk about how it works, if you want.

I’ve confused myself with both of those in previous learning experiences….



Win Treese
> --
> You received this message because you are subscribed to the Google Groups "Land of Lisp" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to land-of-lisp...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/land-of-lisp/e0928a36-42bb-4b46-b33c-19152a538677n%40googlegroups.com.

Reply all
Reply to author
0 new messages