Course Links

Resources

External

This homework consists of five exercises working with higher order functions in OCaml. Just as with the labs and previous homeworks, the assigned tasks are described in comments contained within the code. You can download the starter files here.

You may work with a partner for this assignment if you adhere to the guidelines.

Hints

Proceed in small, discrete steps, making sure that your program compiles each time. If it does not, back up and try again. It is much easier to debug a small section of code than a large one. Use inspection, printing, and compiler error messages to identify and fix any errors.

Remember that you should not write any recursive functions for this assignment. All the recursion will be handled by either transform, filter, or fold, which have already been written for you. Your task instead is to define appropriate helper functions you can pass in to make these do what you want. Pay close attention to the types of the inputs and outputs as you work out what to do. In most cases it will be easiest to create an anonymous function to pass as input, but if you prefer to create a named function you may do that instead.

Remember that each time you change your program, you need to compile it again before you run it. The commands to do that are:

ocamlopt -o hw_hof assert.ml hw_hof.ml
./hw_hof

To Submit