<s>
ML	B-Algorithm
(	O
Meta	O
Language	O
)	O
is	O
a	O
general-purpose	B-Language
functional	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
It	O
is	O
known	O
for	O
its	O
use	O
of	O
the	O
polymorphic	B-Application
Hindley	B-Algorithm
–	I-Algorithm
Milner	I-Algorithm
type	I-Algorithm
system	I-Algorithm
,	O
which	O
automatically	O
assigns	O
the	O
types	O
of	O
most	O
expressions	O
without	O
requiring	O
explicit	O
type	O
annotations	O
,	O
and	O
ensures	O
type	O
safetythere	O
is	O
a	O
formal	O
proof	O
that	O
a	O
well-typed	O
ML	B-Algorithm
program	O
does	O
not	O
cause	O
runtime	O
type	O
errors	O
.	O
</s>
<s>
ML	B-Algorithm
provides	O
pattern	B-Language
matching	I-Language
for	O
function	O
arguments	O
,	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
imperative	B-Application
programming	I-Application
,	O
call-by-value	O
and	O
currying	B-Application
.	O
</s>
<s>
It	O
is	O
used	O
heavily	O
in	O
programming	O
language	O
research	O
and	O
is	O
one	O
of	O
the	O
few	O
languages	O
to	O
be	O
completely	O
specified	O
and	O
verified	O
using	O
formal	B-Application
semantics	I-Application
.	O
</s>
<s>
Its	O
types	O
and	O
pattern	B-Language
matching	I-Language
make	O
it	O
well-suited	O
and	O
commonly	O
used	O
to	O
operate	O
on	O
other	O
formal	O
languages	O
,	O
such	O
as	O
in	O
compiler	O
writing	O
,	O
automated	B-Application
theorem	I-Application
proving	I-Application
,	O
and	O
formal	O
verification	O
.	O
</s>
<s>
Features	O
of	O
ML	B-Algorithm
include	O
a	O
call-by-value	O
evaluation	B-Language
strategy	I-Language
,	O
first-class	B-Application
functions	I-Application
,	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
through	O
garbage	B-General_Concept
collection	I-General_Concept
,	O
parametric	O
polymorphism	B-Application
,	O
static	O
typing	O
,	O
type	O
inference	O
,	O
algebraic	O
data	O
types	O
,	O
pattern	B-Language
matching	I-Language
,	O
and	O
exception	B-General_Concept
handling	I-General_Concept
.	O
</s>
<s>
ML	B-Algorithm
uses	O
static	O
scoping	O
rules	O
.	O
</s>
<s>
ML	B-Algorithm
can	O
be	O
referred	O
to	O
as	O
an	O
impure	O
functional	B-Language
language	I-Language
,	O
because	O
although	O
it	O
encourages	O
functional	B-Language
programming	I-Language
,	O
it	O
does	O
allow	O
side-effects	O
(	O
like	O
languages	O
such	O
as	O
Lisp	B-Language
,	O
but	O
unlike	O
a	O
purely	O
functional	B-Language
language	I-Language
such	O
as	O
Haskell	B-Language
)	O
.	O
</s>
<s>
Like	O
most	O
programming	O
languages	O
,	O
ML	B-Algorithm
uses	O
eager	O
evaluation	O
,	O
meaning	O
that	O
all	O
subexpressions	O
are	O
always	O
evaluated	O
,	O
though	O
lazy	O
evaluation	O
can	O
be	O
achieved	O
through	O
the	O
use	O
of	O
closures	B-Language
.	O
</s>
<s>
Thus	O
one	O
can	O
create	O
and	O
use	O
infinite	O
streams	O
as	O
in	O
Haskell	B-Language
,	O
but	O
their	O
expression	O
is	O
indirect	O
.	O
</s>
<s>
ML	B-Algorithm
's	O
strengths	O
are	O
mostly	O
applied	O
in	O
language	O
design	O
and	O
manipulation	O
(	O
compilers	O
,	O
analyzers	O
,	O
theorem	O
provers	O
)	O
,	O
but	O
it	O
is	O
a	O
general-purpose	B-Language
language	O
also	O
used	O
in	O
bioinformatics	O
and	O
financial	O
systems	O
.	O
</s>
<s>
ML	B-Algorithm
was	O
developed	O
by	O
Robin	O
Milner	O
and	O
others	O
in	O
the	O
early	O
1970s	O
at	O
the	O
University	O
of	O
Edinburgh	O
,	O
and	O
its	O
syntax	O
is	O
inspired	O
by	O
ISWIM	B-Language
.	O
</s>
<s>
Historically	O
,	O
ML	B-Algorithm
was	O
conceived	O
to	O
develop	O
proof	O
tactics	O
in	O
the	O
LCF	O
theorem	O
prover	O
(	O
whose	O
language	O
,	O
pplambda	O
,	O
a	O
combination	O
of	O
the	O
first-order	O
predicate	O
calculus	O
and	O
the	O
simply-typed	O
polymorphic	B-Application
lambda	B-Language
calculus	I-Language
,	O
had	O
ML	B-Algorithm
as	O
its	O
metalanguage	O
)	O
.	O
</s>
<s>
Today	O
there	O
are	O
several	O
languages	O
in	O
the	O
ML	B-Algorithm
family	O
;	O
the	O
three	O
most	O
prominent	O
are	O
Standard	B-Language
ML	I-Language
(	O
SML	B-Language
)	O
,	O
OCaml	B-Language
and	O
F#	B-Operating_System
.	O
</s>
<s>
Ideas	O
from	O
ML	B-Algorithm
have	O
influenced	O
numerous	O
other	O
languages	O
,	O
like	O
Haskell	B-Language
,	O
Cyclone	B-Language
,	O
Nemerle	B-Application
,	O
ATS	B-Language
,	O
and	O
Elm	B-Language
.	O
</s>
<s>
The	O
following	O
examples	O
use	O
the	O
syntax	O
of	O
Standard	B-Language
ML	I-Language
.	O
</s>
<s>
Other	O
ML	B-Algorithm
dialects	O
such	O
as	O
OCaml	B-Language
and	O
F#	B-Operating_System
differ	O
in	O
small	O
ways	O
.	O
</s>
<s>
The	O
factorial	O
function	O
expressed	O
as	O
pure	O
ML	B-Algorithm
:	O
</s>
<s>
Much	O
of	O
ML	B-Algorithm
code	O
is	O
similar	O
to	O
mathematics	O
in	O
facility	O
and	O
syntax	O
.	O
</s>
<s>
The	O
function	O
also	O
relies	O
on	O
pattern	B-Language
matching	I-Language
,	O
an	O
important	O
part	O
of	O
ML	B-Algorithm
programming	O
.	O
</s>
<s>
This	O
implementation	O
of	O
the	O
factorial	O
function	O
is	O
not	O
guaranteed	O
to	O
terminate	O
,	O
since	O
a	O
negative	O
argument	O
causes	O
an	O
infinite	B-Algorithm
descending	I-Algorithm
chain	I-Algorithm
of	O
recursive	O
calls	O
.	O
</s>
<s>
The	O
problematic	O
case	O
(	O
when	O
n	O
is	O
negative	O
)	O
demonstrates	O
a	O
use	O
of	O
ML	B-Algorithm
's	O
exception	O
system	O
.	O
</s>
<s>
The	O
function	O
can	O
be	O
improved	O
further	O
by	O
writing	O
its	O
inner	O
loop	O
as	O
a	O
tail	B-Language
call	I-Language
,	O
such	O
that	O
the	O
call	B-General_Concept
stack	I-General_Concept
need	O
not	O
grow	O
in	O
proportion	O
to	O
the	O
number	O
of	O
function	O
calls	O
.	O
</s>
<s>
This	O
function	O
is	O
an	O
example	O
of	O
parametric	O
polymorphism	B-Application
.	O
</s>
<s>
Modules	O
are	O
ML	B-Algorithm
's	O
system	O
for	O
structuring	O
large	O
projects	O
and	O
libraries	O
.	O
</s>
<s>
The	O
signature	O
file	O
specifies	O
the	O
API	B-General_Concept
to	O
be	O
implemented	O
(	O
like	O
a	O
C	O
header	O
file	O
,	O
or	O
Java	B-Language
interface	I-Language
file	O
)	O
.	O
</s>
<s>
The	O
structure	O
implements	B-Language
the	O
signature	O
(	O
like	O
a	O
C	O
source	O
file	O
or	O
Java	O
class	O
file	O
)	O
.	O
</s>
<s>
ML	B-Algorithm
's	O
standard	O
libraries	O
are	O
implemented	O
as	O
modules	O
in	O
this	O
way	O
.	O
</s>
