Re: A simple Lisp program
Posted: Wed Dec 29, 2010 12:45 pm
Oh, try this:
Replace this:
With this version:
The new version doesn't change anything, but it does tell you what the programs state was when its finished. That might help you track down the problem. What I think is happening, is that we are binding the variable X to the string "this is a phony string" --- but because interpret-program only returns the output, we don't see that we've successfully made a memory binding.
I think you'll see something like:
MEMORY: ((x . "this is a phony string"))
Replace this:
Code: Select all
(defun interpret-program (program input)
(third (interpret-statement-list program (list '(()) input nil))))
Code: Select all
(defun interpret-program (program input)
(destructuring-bind (memory input output) (interpret-statement-list program (list '(()) input nil))
(format t "~%DONE...~%MEMORY: ~s~%INPUT: ~s~%OUTPUT: ~s" memory input output)))
I think you'll see something like:
MEMORY: ((x . "this is a phony string"))