Now let's look closer at the syntax of anonymous functions:
fun x1 ... xn -> e
fun is a keyword meaning that we're declaring a functionx1 ... xn are parameters. You can name them in any way that you can name variablese is the function body. It's an expression.e) isn't evaluated until the function is applied.A common mistake that people make is that people think the body of the function is evaluated when it's declared.
Anonymous functions are also known as lambda expressions. This comes from math, with λx.e being the notation. The λ means that "what follows is an anonymous function," like the fun keyword in OCaml.
Lambdas are popular in many languages
Functions as values is a design decision in OCaml. We can use functions anywhere we use values. Functions can take functions as parameters, and functions can return functions. This is one of the main principles of functional programming.