*** Welcome to piglix ***

Caml

Caml
Caml.gif
Paradigm multi-paradigm: functional, imperative; object-oriented in OCaml
Designed by Gérard Huet, Guy Cousineau, Ascánder Suárez, Pierre Weis, Michel Mauny (Heavy Caml), Xavier Leroy (Caml Light, OCaml)
First appeared 1985
Stable release
4.04.0 / November 4, 2016; 2 months ago (2016-11-04)
Typing discipline strong, static, inferred
OS Cross-platform
Website caml.inria.fr
Major implementations
OCaml, Caml Light
Influenced by
ML
Influenced
F#

Caml (originally an acronym for Categorical abstract machine language) is a dialect of the ML programming language family, developed at INRIA and formerly at ENS.

Like many descendants of ML, Caml is statically typed, strictly evaluated, and uses automatic memory management.

OCaml is currently the main implementation of Caml, and adds many new features to the language including an object layer.

In the following, # represents the OCaml prompt.

Many mathematical functions, such as factorial, are most naturally represented in a purely functional form. The following recursive, purely functional Caml function implements factorial:

The function can be written equivalently using pattern matching:

This latter form is the mathematical definition of factorial as a recurrence relation.

Note that the compiler inferred the type of this function to be int -> int, meaning that this function maps ints onto ints. For example, 12! is:

Since OCaml is a functional programming language, it is easy to create and pass around functions in OCaml programs. This capability has an enormous number of applications. Calculating the numerical derivative of a function is one such application. The following Caml function d computes the numerical derivative of a given function f at a given point x:

This function requires a small value delta. A good choice for delta is the cube root of the machine epsilon.


...
Wikipedia

...