What does it mean "Observation: Functions are first-class values in this language"?

What does it mean “Observation: Functions are first-class values in this language”?

functions can be used as any other value (like an int for example),
you can make a let binding, put it inside a list or any other structure, pass it as parameter to another function.
examples:

let f = (fun v -> v + 1)
let f_list = [f; f; f]
let f_some = Some f
List.map f [1; 2; 3]
1 Like

A longer explanation on Wikipedia:
https://en.wikipedia.org/wiki/First-class_function

1 Like

You can treat a function like any other value in the language. Historically in many other languages this was either not possible, or difficult to do. OCaml makes it trivial to use functions as if they were any other value… for example, you can bind a function to a variable and pass that variable to another function. You can create lists of functions, etc…

1 Like