Ocaml track: assignment 2: data structures and algorithms


Goals

To learn how to create and manipulate simple data structures in ocaml.

Language concepts covered this week

Reading

Chapters 4-6 of the textbook.

Program to write

Once again, you will be writing a series of independent functions and supporting code rather than a full-blown program. Write them all in a file called lab2.ml. Here are the functions and data types you have to write. I've put the number of lines of ocaml code I used in my solution in brackets after the description of each function/type/etc. Your code can be longer than mine if you wish, but it's fun to try to write the code concisely (without playing typographical games e.g. eliminating newlines).

To hand in

Your file lab2.ml. Note that you may have to put double-semicolons (;;) at the end of expressions in a few places in your file to allow the file to be executed with your test cases left in. The compiler will tell you where those places are ;-)

Supporting files

None.

References