I'm trying to teach myself some LISP and while I understand most of it, I have trouble grasping the eval function. I know that it does it for us already and that it's not good to use (so I hear), but how would I make a function that just adds?
So far I was attempting/thinking
(setf input-prompt "Enter addition epression: ")
(setf output-prompt "The value is: ")
(defun prompt-for-input (msg)
(format t msg))
(defun sum (expression)
(format t "Summing ~d and ~d.~%" x y)
(+ x y))
(defun add ()
(prompt-for-input input-prompt)
(let ((expression (read)))
((sum (expression)))
(add)))
Not really sure where to go on this, any help is appreciated.
eval
. This is basically writing a small interpreter, which is something covered in most Lisp books (Little Schemer, etc.). But it would help if you could describe your problem more clearly. – user725091