Recitation 1

This recitation is a bit longer than most will be, because we need to hit the ground running. The questions below are designed to guide your initial explorations of OCaml. Use sections 2.2 through 2.5 of the textbook, the manual, and the other students in your recitation section to help you!

  1. For each of the following, investigate what OCaml has, and explain in your own words how OCaml compares to another language of your choice (perhaps Java or Python). Make sure to try out examples in the toplevel.

    • primitive types
    • operators
    • assertions

  2. How do OCaml if expressions compare and contrast with if commands in imperative languages, such as Java and Python? And with ternary operators? (If you’re not already familiar with ternary operators in those languages, now’s a good time to look them up!)

  3. When using the OCaml build system, what files get created, and where are they are located? Experiment as necessary to find out.

  4. Choose one or two simple mathematical functions and implement them in OCaml. If you need inspiration, perhaps think of some simple equations from a physics or algebra or statistics class. All the built-in mathematical functions (e.g., sin, log, etc.) are described in the documentation of the Pervasives module, in case you need them.

Submit to CMS: Submit your answers to the questions above. Type your answers. Please do not submit handwritten answers. Keep it brief—definitely no more than one page. For the last question, just include your code as part of your written answers. There’s no need to submit a .ml file.