From what my teacher told me, I should use let to declare local variables and setf to declare global variables.
I'm tried running the following code:
(let (state-list (problem-initial-state problem))
(print state-list))
and I get NIL.
However, when I try the following:
(setf state-list (problem-initial-state problem))
(print final-list)
I get the desired value (the value in problem-initial-state problem).
Why is that?
PS: I apologize for these begginer questions, I'm getting a hard time getting into LISP, coming from a C background.
You are missing a couple of parens in your let
forms:
(let ((a 1)
(b 2))
(print (list a b)))
will print (1 2)
.
Your form
(let (state-list (problem-initial-state problem))
(print state-list))
binds state-list
to nil
and problem-initial-state
to problem
.