All of the following functions that operate on trees should be recursive. Some functions that you may need are provided in the file Cons.java . This assignment may be done in Java or in Lisp.
Operators have precedence, which determines the
order in which operations are performed when an expression is not
parenthesized. We will assume that = has precedence 1,
+ - have precedence 5, and * / have precedence 6.
A subexpression needs to be parenthesized if its precedence is less
than or equal to the precedence of its surroundings; otherwise, it
should not be parenthesized. Make an auxiliary function that
includes precedence as an argument. The starting precedence can be 0,
so that any operator will be higher in precedence.
Example: (tojava '(= x (* (+ a b) c))) = "x=(a+b)*c;"
We will assume that a unary minus should always be parenthesized, and that it has a precedence of 6.
For functions that are not in the operator list, such as sin, make the name be Math. followed by the function name, and make a function call form. For example, (sin x) would become "Math.sin(x)" .