A guide for how to attack an MP:
- In your svn repository dircetory, or its
subdirectory assignments, do an svn up to retrieve
the directory mpX for the MP and all its
contents. Go into that directory. (If we need to revise an
assignment, you will need to repeat the svn up to obtain
- To make sure you have all the
necessary pieces, start by executing make. This will create
the grader executable. Run the executable
(./grader). Examine the failing test cases for places where
errors were produced by your code. At this point, everything should
compile, but the score will be 0.
- Read and understand the problem for the handout on which you wish to
begin working. (Usually, working from top to bottom makes most
sense.) There is a tests file in this directory. This is
an important file containing the an incomplete set of test cases;
you'll want to add more cases to test your code more thoroughly.
Reread the problem from the handout, examining any sample output
given. Open the tests file in the
mpX directory. Find the test cases
given for that problem. Add your own test cases by following the
same pattern as of the existing test cases. Try to get a good
coverage of your function's behaviour. You should even try to have
enough cases to guarantee that you will catch any errors. (This is
not always possible, but a desirable goal.) And yes, test cases
should be written even before starting the implementation of your
function. This is a good software development practice.
- If necessary, reread the statement of the problem once more. Place
your code for the solution
or mpX.mly as specified by
the assignment instructions)
replacing the stub found there for it. Implement your function.
Try to do this in a step-wise fashion. When you think you have a
solution (or enough of a part of one to compile and be worth
testing), save you work and execute make and the
./grader again. Examine the passing and failing test cases
again. Each failure is an instance where your code failed to give
the right output for the given input, and you will need to examine
your code to figure out why. When you are finished making a round
of corrections, run make, followed by ./grader
again. Continue until you find no more errors. Consider submitting
your partial result so that you will at least get credit for what
you have accomplished so far, in case something happens to interfere
with your completing the rest of the assignment.
- When your code no longer generates any errors for the problem on
which you were working, return to steps 3) and 4) to proceed with
the next problem you wish to solve, until there are no more problems
to be solved.
- When you have finished all problems (or given up and left the
problem with the stub version originally provided), you will need to
submit your file to the svn repository, and described in the previous
In addition to running "make" and "grader", you probably want to test
and debug your code interactively at the top level:
- Enter the directory with your source file.
- Type ocaml at the command line.
- Type #load "mpXcommon.cmo";; at the OCaml
prompt, where X is the number of the assignment (this loads in the
common stuff that we give you in compiled form by default).
- Type #use "mpX.ml";; at the OCaml prompt, where
X is the number of the assignment. This loads in your code, and adds
the functions you have defined to the identifiers recognized at top
- Type in commands followed by ';;' at the OCaml
prompt to test
your code interactively. Anything that you can do in a code file, you
can do interactively. For example, you can define identifiers using
'let x = ...', etc...
- With each MP, you will be given a solution in compiled form.
You may interactively test the solution to a problem, after having
loaded "mpXcommon.cmo", by loading the solution file
by typing #load "solution.cmo";;. After that, if
you are supposed to write a function called, say
splat, and wish to fine out what it does on an
input, say 39.2, you make execute the solution's
version of splat by typing Solution.splat
39.2;;. Notice the capitalization.