Assignment 10, due Apr 12

Part of the homework for CS:2820, Spring 2019
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top of each page. Write your name as it appears in your university records! Use the section number for which you are registered! We will not do detective work to figure out who did what. Work must be legible.

Homework is due on paper in discussion section, usually at the start except when the assignment indicates that time to work on the assignment will be provided in class. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God" outside your control). Never push homework under someone's door!

  1. Background: Enough people had difficult on the exam that it's worth going back and working on some λ-expressions. Here's a Java main program:
    public static void main( String[] args ) {
        X      p = (String s) -> "p( " + s + " )";
        Y      q = (X j) -> ( (String s) -> j.x( j.x( s ) ) );
        X      r = q.y( p );
        System.out.println( "Value is: " + r.x( "one" ) );
    }
    

    Given an appropriate class wrapping this code, along with appropriate definitions for X and Y, this code can be compiled.

    a) Give the Java definitions for X and Y. (0.5 points)

    b) What output would you expect from this main program? (0.5 points)

  2. Background: The posted solution to MP4 uses class IncountGate as a crutch to implement classes XorGate and ThresholdGate. It maintains an instance variable oldOutput for just one purpose, to determine if an input change requires any change to the output.

    In both parts of this problem, you are to consider two successive calls to outputChange for some particular gate, comparing the parameter value to the value of oldOutput. In the code given, the value of oldOutput is not visible in method outputChange. That does not mean that it does not exist, so on paper, we can still compare the values.

    a) Suppose that the simulated time interval between the two successive calls is longer than the delay of the gate. What is the relationship between value and oldOutput at the first call? At the second call? (0.5 points)

    b) Suppose that the simulated time interval between the two successive calls is shorter than the delay of the gate. What is the relationship between value and oldOutput at the first call? At the second call? (0.5 points)

  3. Background: Run Javadoc on the distributed solution to MP4.

    a) How many .html files does it create? (0.5 points)

    b) Explore the documentation, starting with the index.html file. Is it useful? Why or why not? (0.5 points)