LISP (List Processing) is a family of programming languages where the program is composed solely of linked lists.
Each list in any Lisp dialect is surrounded by parentheses, with the elements delimited by spaces (and ordered from left to right). The first element is assumed to be the function, and the remaining elements are the parameters to this function. A list of this form is also called an s-expression.
For example:
(+ 1 2 3)
Is a simple program in Lisp which would evaluate to 6
An atomic list is a list that contains no other lists. Your goal is to implement addition, multiplication, and subtraction over atomic lists according to the specified interface.
Note: If you are compiling from the command line
(i.e. not Eclipse), you can have javac locate the library
by properly setting the CLASSPATH:
export CLASSPATH="path/to/jar:."
Write a class called Lisp which will be responsible for evaluating expressions in a simple variant of LISP.
Your class must do the following:
The very first operation eval should perform is a call to read
Lisp thisInstance = new Lisp();
String programResult = Parser.getSexp(thisinstance);
In addition, you might find the following methods useful:
Welcome to the simple lisp evaluator.
Enter an s-expression or type (exit) to quit.
-> (+ 1 2)
3
-> (- 1 (+ 1 2) (* 3 4))
-14
-> (- 0 1)
-1
-> (- 0 1 1 1)
-3
-> (+ 1 2 3 4)
10
-> (exit)
Goodbye
Upload the .java file to the dropbox