02 Anonymous Functions

The most basic kind of function in OCaml is the anonymous function.

This anonymous function takes in an argument, x, and returns x + 1.

What does this output mean?

This has a lot of parallels to other things we've seen.

Here we have the anonymous integer 3110. See the -? That means it's anonymous.

Let's try to call our function!

In OCaml, we just write our arguments immediately after our function. Here, 3110 is parsed as the argument and fun x -> x + 1 is the function.

Here we have a function that takes the average of two floats.

We can also call this function the same way!