I'm making an interpreter for an esoteric programming language, and I made this program for it. However, instead of giving the desired output, it outputs
*** - EVAL: undefined function X
Can anyone help clarify the problem with this program?
I've already tried googling this error, and checking similar questions on this site.
(setq acc 0)
(loop
(setq x (read-char))
(when (x = #\i)(acc(+ acc 1)))
(when (x = #\d)(acc(- acc 1)))
(when (x = #\s)(acc(* acc acc)))
(when (x = #\o)(write(acc)))
(when (x = #\h)(return x))
(when (acc <0 or acc =255)(acc =0)))
The input "iiiso" should give the output 9.
However, the actual output is
*** - EVAL: undefined function X
You really need to start with a good lisp book, e.g., PCL or ACL. You will save yourself a lot of time.
Lisp syntax is different from C.
In C, equality
==is an infix operator, used asx == 1. In Lisp equality predicates=,eql&c are ordinary functions.Thus you need to write
(eql x #\i).This is, however, just one of many other problems with your code. You do need to get a textbook.
See also clisp: variable has no value.