CSci 555-1: Functional Programming
Spring 2016

Assignment #1
Due Thursday, 18 February, 2016


Complete the following programming tasks by the due date.

  1. Modify and extend the expression-tree calculator program based on case classes given in the handout Notes on Scala for Java Programmers in the following ways:

    1. Change Const to represent floating point numbers instead of integers.
    2. Add the following new kinds of nodes: Sub, Prod, and Div for subtraction, multiplication, and division of values, respectively; Neg for negating a value, and Sin and Cos for the sine and cosine trigonometric functions, respectively. Extend functions eval and derive to support these additions.
    3. (Optional, but recommended, for Undergraduates) 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.
    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).

  2. Modify and extend the expression-tree calculator program based on traditional object-oriented techniques in the same manner as the previous task.
  3. Design appropriate tests for your program and test the program thoroughly.
  4. Document your program appropriately.
  5. 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 555 Assignments?


Copyright © 2016, H. Conrad Cunningham
Last modified: Wed Apr 10 12:14:12 CDT 2019