Assignment 2: More OCaml

You are to write several OCaml functions, similar to what you had in assignment 1 but using more OCaml features. The instructions below are more or less identical to assignment 1.

  • Use this zip file as the starting point for your assignment. Download and unzip it.
  • The file assignment2/src/assignment.ml is where you will put your answer code. Currently it has unimplemented () or similar for all the functions, replace that with your code.
  • The only other file you might want to edit is assignment2/tests/tests.ml which contains some initial tests; you are welcome to add your own tests.
  • The terminal command dune build run from the top level assignment2/ directory will build (compile) all your functions in the assignment.ml file.
  • The terminal command dune test also run from assignment2/ will build the code and run all the tests in the above test.ml file. It will report on each test whether it succeeded or failed.
  • To play with your code in utop, you could copy/paste your functions directly into the top loop, but a perhaps easier way is to type terminal command dune utop, again from the assignment2/ directory. This will compile all your functions and load them into utop. They will all be part of a module Assignment since the file was called assignment.ml; so, next type open Assignment;; into utop so the functions will be directly available.
  • When you are all done the homework, from directory assignment2/ run the command dune build one last time which will build _build/default/src/submission.zip – that is the zip file you should upload to Gradescope.

Submission and Grading

  • This follows HW1: when prompted by Gradescope, upload your _build/default/src/submission.zip file generated by dune build.
  • As with assignment 1 there will be additional tests we run which you will not see the output of. Also we will be manually checking to make sure your code meets the specification.