OCaml Warm-Up
Due on Wednesday, February 17th at 11:59 PM. This is an individual lab. You are to complete this lab on your own, although you may discuss the lab concepts with your classmates. Remember the Academic Integrity Policy: do not show your code to anyone outside of the course staff and do not look at anyone else’s code for this lab. If you need help, please post on the Piazza forum or contact the instructor. If you have any doubts about what is okay and what is not, it’s much safer to ask than to risk violating the Academic Integrity Policy.
Overview
This lab will serve as an introduction to OCaml. You will write a series of functions and other snippets of code designed to familiarize you with the language. This will also ensure that your environment is prepared so you don’t have trouble in later assignments.
Getting Started
First and foremost, you must have an OCaml development environment. While it is possible to program in OCaml on a variety of platforms, we are preparing to develop a compiler. Since compilers are very machine-specific tools, you should use the course virtual machine if at all possible. Contact your instructor if you need to make alternate arrangements.
Working on the Lab
Once you have configured your OCaml development environment as described above, you can check out your assignment using the following command, replacing <username>
with your Swarthmore username:
git clone git@github.swarthmore.edu:cs75-s21/ocaml1-<username>
Your job in this assignment is to open each of the .ml
source files in your repository and complete the implementation tasks within. There are several files and you are encouraged to complete them in the following order:
helloWorld.ml
functions.ml
linkedLists1.ml
linkedLists2.ml
breakfast.ml
tests.ml
Throughout these files, there are several calls to failwith
using a string starting with “TODO
”; there are also comments containing the string “TODO
”. Your assignment will be complete when every one of these TODO
s has been replaced with appropriate code.
It may take you a while to become accustomed to a new language, so be patient with yourself. You may wish to keep the OCaml Transition Guide open as you work on the assignment so you can use it to help you make the shift from the languages you know to OCaml.
As a clarification for those who may already know OCaml or choose to explore the features of the language: you are not permitted to use any of the following when you are completing your assignment:
- Mutation (e.g.
ref
cells) - Imperative loops (
for
andwhile
) - Standard library modules (except
Stdlib
or where otherwise noted)
If you don’t know what the above means, don’t worry! Everything you learned in lecture is fine to use in this assignment.
Submitting
To submit your lab, just commit and push your work. The most recent pushed commit as of the due date will be graded. For more information on when assignments are due, see the Policies page.
After each lab, you will complete a brief questionnaire found here. In most cases, the questionnaire should take less than a minute. This questionnaire is required and will be used as part of your participation grade.
If You Have Trouble…
…then please contact your instructor! Slack is the preferred method, but you can reach out via e-mail as well. Good luck!