CS 1410-20 Homework 10

Due: Friday, November 11th, 2011 11:11am

Start with eval.zip.

Part 1 – Absolute Value

Add support for an abs expression, which has a single sub-expression for its argument and produces the absolute value of its argument’s value.

For example, if you call your new class Abs, then new Abs(new Num(-5.0)).eval() should produce 5.0.

Part 2 – Functions

Like parts 4 and 5 of HW 7, add function definitions and function-call expressions to the evaluator. You will need to change the eval method in IExpr to accept a list of definitions as an argument.

The factorial function is a traditional toy example to demostrate an evaluator. Make sure your function tests include calling the factorial function on 5.0 (like the last example shown for part 5 of HW 7).


Last update: Friday, November 4th, 2011
mflatt@cs.utah.edu