Lab 5

20 points

Part 1. Create a file with the following functions and then run OEVAL on a 10 simple lisp expressions [e.g. (OEVAL '(CAR (CDR (QUOTE (A B C))))) ]. You must create the functions First, Second and Rest. Get lisp interpreters from links in the syllabus.

(DEFUN ISCONS (X)
       (COND  (( OR (EQ X T) (NULL X)) T)
               (T NIL)))
(DEFUN OEVAL  (X)
       (COND  ((ISCONS X) X)
              ((ATOM X) (PROGN (PRINT "UNBND ATOM")
               (TERPRI) NIL))
              (T (OAPPLY (FIRST X) (REST X)))))
(DEFUN OAPPLY (FN ARGS)
       (COND  ((EQ FN 'CAR)  (CAR (OEVAL(FIRST ARGS))))
              ((EQ FN 'CDR)  (CDR (OEVAL(FIRST ARGS))))
              ((EQ FN 'CONS) (CONS(OEVAL(FIRST ARGS))
                                  (OEVAL(SECOND ARGS))))
              ((EQ FN 'QUOTE) (FIRST ARGS))
              ((EQ FN 'ATOM ) (ATOM(OEVAL(FIRST ARGS))))
              ((EQ FN 'EQ   ) (EQ(OEVAL(FIRST ARGS))
                                 (OEVAL(SECOND ARGS))))))

Part 2. Create your own Pascal or C++ functions EVAL and APPLY. You will also have to create the functions CAR, CDR, CONS, FIRST, SECOND, ATOM and EQ. Run the same test programs you used in Lab 5 to test your Pascal or C++ version of the program.To get the lisp parser click here. For the c++ version of the parser click here .