Functions are central in OCaml. We’ll learn about functions with a few different examples.
To run this OCaml program, you would typically save it in a file with a .ml extension, for example functions.ml, and then use the OCaml compiler or interpreter:
Alternatively, you can compile it to a native executable:
There are several other features to OCaml functions. One is pattern matching, which we’ll look at in future examples.