Note Learning Lisp
I am getting this error:
Illegal argument in functor position: (EVALEXP (CDR MAIN-LIST) BIND-LIST)
in ((EVALEXP(CDR MAIN-LIST) BIND-LIST))
from this:
(defun evalexp (main-list bind-list)
(if (eq nil (cdr main-list))
( (if (eq nil (atom (car main-list))) (evalexp (car main-list) bind-list) ) )
( (print (car main-list))
(evalexp (cdr main-list) bind-list) )
)
main-list contains this list:
(and 1 (or a b))
What is in bind-list doesn’t matter because I am not using it yet. I am trying to loop through the list printing out each car. Any ideas why I am getting this error?
Extra parentheses.
Normally the first thing after an opening parenthesis is a function name. You have another opening parenthesis there in some cases, which is a syntax error, as you saw.
You also seem to want a statement block.
prognoften fits the bill. You could use a block for the innerif, but it’s really not necessary since it would contain only one statement.