Assignment 2

Recursive functions. GitHub issues.

You may need to refer to the Pervasives module documentation occasionally. All the functions there are available in OCAML by default. You are NOT allowed to use everything that’s there unless we have talked about it or unless the assignment question asks you to look it up.

In this assignment you are asked to implement 9 functions. Each function is worth two points, and the assignment has two extra points for “style”, for a total of 20 points.

The assignment expects you to use GitHub and Git to keep track of your work. You have already set up GitHub on your first assignment. What we need to do now is “update” your GitHub with the new information. This is a somewhat delicate process, as your “branch” has deviated from the instructor’s “branch”, and we need to realign them.

  1. The first thing we need to do is set up the instructor’s repository as a remote repository you can access. You will only have to do this first step once, while the other steps you will have to repeat for each assignment.
  2. Now we need to download the updated version of the instructor’s repository and merge the changes into ours.
  3. From this assignment on, we will start developing an issue-driven methodology for your assignments. Every individual item you are working on should have a corresponding GitHub issue associated with it, and when you “commit” your work you would also be closing the issue. Here is the process for doing so:
    let f (x : int) = (x, 1)
    where of course you need to make sure these are the “right things” type-wise. The point of this part is to get the function signature right. So the value you use on the right may be completely wrong, for now, but we just want it there to correctly identify the types of functions.
  4. From this point on you will repeat this process for each individual function:
  5. You will find two files in this directory:
  6. To “run” your tests, start an OCAML session in the terminal via utop, do:
#use "assignment2sub.ml";;
#use "assignment2tests.ml";;

You should be able to use auto-completion. - The first #use should print for you the type signatures for all the functions you had to write. Make sure this matches the signatures described in the code file. - The second #use should print a bunch of true values out, for all the existing tests along with all the tests you added.