CSci 658: Software Language Engineering
Fall 2013
Assignment #1
Due 11:49 p.m., 19 September 2013
(Extended by 2 days)
Complete the following programming tasks by the due date. The
program you develop should use functional programming techniques.
That is, your program can create data structures and initialize them,
but it should not change the values of the data structure once
initialized.
- Modify and extend one of the three functional implementations of
the Arithmetic Expression Tree skeleton program on the Lecture Notes page in the
following ways:
- Add the following new kinds of nodes: Sub,
Prod, and Div for subtraction, multiplication, and
division of numbers, respectively; Neg for negating a value,
and Sin and Cos for the sine and cosine
trigonometric functions, respectively.
- Extend functions eval, derive, and
valToString to support these new node types. (For
differentiation, you may want to look up the formulas in a Calculus
textbook to remind yourself of the more complex rules.)
- Add a new operation simplify that takes an
expression tree (as extended in the previous tasks), simplifies it by
"evaluating" all subexpressions involving only
constants (not evaluating variables), and returns the new expression.
For example, Add(Const(1),Const(3)) can be simplified to
Const(4).
- Challenge: Extend the simplifications in other ways. For
example, you could take advantage of mathematical properties such as
identity elements (x * 1 = x), zeros (x * 0 = 0),
associativity ((x + y) + z = x + (y + z), and commutativity
( x + 1 = 1 + x).
- Design appropriate tests for your program and test the program
thoroughly.
- Document your program appropriately.
- Submit the source code and documentation for your program and
test driver, any needed instructions on how to run the program, and
appropriate test output to Blackboard. Also provide your instructor
with a paper copy. Be sure to identify yourself in the materials
turned in.
UP to CSci 658 assignments document?
Copyright © 2013, H. Conrad Cunningham
Last modified: Thu Sep 12 20:19:53 CDT 2013