Programming Assignment 4
CS 31600
Programming Languages
Spring, 2021

This assignment makes use of the files contained in this zip file. This assignment is due Tuesday, March 30.

This is your third programming assignment using ML. This assignment is based on the recursive function examples that we did in class.

In the zip file there is a file hw4.sml that describes all the recursive functions that you need to define. Write your definitions for the functions in that file. Be sure to test your solutions to these problems. You should put your test code in a file hw4-my-tests.sml. (Don't put your test code inside of hw4.sml.) You can run your tests by starting the SML repl and then loading your code,

 - use "hw4.sml";

followed by loading your tests,

 - use "hw4-my-tests.sml";

Here is one way to implement your tests. In problem 1 you are given the following examples of input and output for the function repeatChar.

 repeatChar (5, #"P") ==> "PPPPP"
 repeatChar (0, #"P") ==> ""

You can turn these examples into test cases by writing them in hw4-my-tests.sml this way.

 repeatChar (5, #"P") = "PPPPP";
 repeatChar (0, #"P") = "";

This turns the input/output pair into a boolean expression. If repeatChar returns the correct value, then the boolean expression will evaluate to true, but if repeatChar returns the wrong value, then the boolean expression will evaluate to false. If you construct all of your tests this way, then when you run hw4-my-tests.sml you want to see a long list of trues.

In the file hw4-my-tests.sml I have already converted all the example input/output pairs into "boolean test cases". You still need to add more test cases. The ones I give you are not enough to know that your functions are correct (and several of the problems don't have any input/output examples given in the problem).

Make sure that your files hw4.sml and hw4-my-tests.sml begin with a ML comment block of the form

 (*
    CS 31600
    Hw 4
    Your_Name_Here
    Your_Email_Address_Here

    Any other comments that you want to make...
 *)

Turn in a zip file called CS316Hw4Surname.zip (where Surname is your last name) containing your versions of hw4.sml and hw4-my-tests.sml.

This assignment is due Tuesday, March 30.