<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
function	B-Application
composition	I-Application
is	O
an	O
act	O
or	O
mechanism	O
to	O
combine	O
simple	O
functions	O
to	O
build	O
more	O
complicated	O
ones	O
.	O
</s>
<s>
Like	O
the	O
usual	O
composition	B-Application
of	I-Application
functions	I-Application
in	O
mathematics	O
,	O
the	O
result	O
of	O
each	O
function	O
is	O
passed	O
as	O
the	O
argument	O
of	O
the	O
next	O
,	O
and	O
the	O
result	O
of	O
the	O
last	O
one	O
is	O
the	O
result	O
of	O
the	O
whole	O
.	O
</s>
<s>
In	O
some	O
cases	O
,	O
the	O
composition	B-Application
of	I-Application
functions	I-Application
is	O
interesting	O
as	O
a	O
function	O
in	O
its	O
own	O
right	O
,	O
to	O
be	O
used	O
later	O
.	O
</s>
<s>
Such	O
a	O
function	O
can	O
always	O
be	O
defined	O
but	O
languages	O
with	O
first-class	B-Application
functions	I-Application
make	O
it	O
easier	O
.	O
</s>
<s>
The	O
ability	O
to	O
easily	O
compose	O
functions	O
encourages	O
factoring	B-Algorithm
(	O
breaking	O
apart	O
)	O
functions	O
for	O
maintainability	O
and	O
code	O
reuse	O
.	O
</s>
<s>
Narrowly	O
speaking	O
,	O
function	B-Application
composition	I-Application
applies	O
to	O
functions	O
that	O
operate	O
on	O
a	O
finite	O
amount	O
of	O
data	O
,	O
each	O
step	O
sequentially	O
processing	O
it	O
before	O
handing	O
it	O
to	O
the	O
next	O
.	O
</s>
<s>
Functions	O
that	O
operate	O
on	O
potentially	O
infinite	O
data	O
(	O
a	O
stream	B-Architecture
or	O
other	O
codata	O
)	O
are	O
known	O
as	O
filters	B-Application
,	O
and	O
are	O
instead	O
connected	O
in	O
a	O
pipeline	B-Operating_System
,	O
which	O
is	O
analogous	O
to	O
function	B-Application
composition	I-Application
and	O
can	O
execute	O
concurrently	B-Architecture
.	O
</s>
<s>
Here	O
is	O
the	O
example	O
in	O
the	O
C	B-Language
language	I-Language
:	O
</s>
<s>
In	O
a	O
stack-based	B-Language
language	I-Language
,	O
functional	B-Application
composition	I-Application
is	O
even	O
more	O
natural	O
:	O
it	O
is	O
performed	O
by	O
concatenation	O
,	O
and	O
is	O
usually	O
the	O
primary	O
method	O
of	O
program	O
design	O
.	O
</s>
<s>
The	O
above	O
example	O
in	O
Forth	B-Application
:	O
</s>
<s>
Example	O
in	O
C	B-Language
:	O
</s>
<s>
Example	O
in	O
Forth	B-Application
:	O
</s>
<s>
In	O
languages	O
such	O
as	O
C	B-Language
,	O
the	O
only	O
way	O
to	O
create	O
a	O
new	O
function	O
is	O
to	O
define	O
it	O
in	O
the	O
program	O
source	O
,	O
which	O
means	O
that	O
functions	O
ca	O
n't	O
be	O
composed	O
at	O
run	B-Library
time	I-Library
.	O
</s>
<s>
In	O
functional	O
programming	O
languages	O
,	O
function	B-Application
composition	I-Application
can	O
be	O
naturally	O
expressed	O
as	O
a	O
higher-order	B-Language
function	I-Language
or	O
operator	O
.	O
</s>
<s>
In	O
other	O
programming	O
languages	O
you	O
can	O
write	O
your	O
own	O
mechanisms	O
to	O
perform	O
function	B-Application
composition	I-Application
.	O
</s>
<s>
In	O
Haskell	B-Language
,	O
the	O
example	O
given	O
above	O
becomes	O
:	O
</s>
<s>
The	O
composition	O
operator	O
itself	O
can	O
be	O
defined	O
in	O
Haskell	B-Language
using	O
a	O
lambda	B-Language
expression	I-Language
:	O
</s>
<s>
-	O
it	O
takes	O
a	O
pair	O
of	O
functions	O
,	O
and	O
returns	O
a	O
function	O
(	O
the	O
lambda	B-Language
expression	I-Language
on	O
the	O
second	O
line	O
)	O
.	O
</s>
<s>
Note	O
that	O
Haskell	B-Language
does	O
n't	O
require	O
specification	O
of	O
the	O
exact	O
input	O
and	O
output	O
types	O
of	O
f	O
and	O
g	O
;	O
the	O
a	O
,	O
b	O
,	O
c	B-Language
,	O
and	O
x	O
are	O
placeholders	O
;	O
</s>
<s>
a	O
polymorphic	B-Application
operator	O
.	O
</s>
<s>
Variants	O
of	O
Lisp	B-Language
,	O
especially	O
Scheme	B-Language
,	O
the	O
interchangeability	O
of	O
code	O
and	O
data	O
together	O
with	O
the	O
treatment	O
of	O
functions	O
lend	O
themselves	O
extremely	O
well	O
for	O
a	O
recursive	O
definition	O
of	O
a	O
variadic	B-General_Concept
compositional	O
operator	O
.	O
</s>
<s>
Many	O
dialects	O
of	O
APL	B-Language
feature	O
built	O
in	O
function	B-Application
composition	I-Application
using	O
the	O
symbol	O
∘	O
.	O
</s>
<s>
This	O
higher-order	B-Language
function	I-Language
extends	O
function	B-Application
composition	I-Application
to	O
dyadic	O
application	O
of	O
the	O
left	O
side	O
function	O
such	O
that	O
A	O
f∘g	O
B	O
is	O
A	O
f	O
g	O
B	O
.	O
</s>
<s>
Additionally	O
,	O
you	O
can	O
define	O
function	B-Application
composition	I-Application
:	O
</s>
<s>
Raku	B-Application
like	O
Haskell	B-Language
has	O
a	O
built	O
in	O
function	B-Application
composition	I-Application
operator	I-Application
,	O
the	O
main	O
difference	O
is	O
it	O
is	O
spelled	O
as	O
∘	O
or	O
o	O
.	O
</s>
<s>
Also	O
like	O
Haskell	B-Language
you	O
could	O
define	O
the	O
operator	O
yourself	O
.	O
</s>
<s>
In	O
fact	O
the	O
following	O
is	O
the	O
Raku	B-Application
code	O
used	O
to	O
define	O
it	O
in	O
the	O
Rakudo	B-Language
implementation	O
.	O
</s>
<s>
In	O
Python	B-Language
,	O
a	O
way	O
to	O
define	O
the	O
composition	O
for	O
any	O
group	O
of	O
functions	O
,	O
is	O
using	O
reduce	B-Application
function	I-Application
(	O
use	O
functools.reduce	O
in	O
Python3	B-Language
)	O
:	O
</s>
<s>
In	O
JavaScript	B-Language
we	O
can	O
define	O
it	O
as	O
a	O
function	O
which	O
takes	O
two	O
functions	O
f	O
and	O
g	O
,	O
and	O
produces	O
a	O
function	O
:	O
</s>
<s>
In	O
C#	O
we	O
can	O
define	O
it	O
as	O
a	O
Func	O
which	O
takes	O
two	O
Funcs	O
f	O
and	O
g	O
,	O
and	O
produces	O
a	O
Func	O
:	O
</s>
<s>
Languages	O
like	O
Ruby	B-Language
let	O
you	O
construct	O
a	O
binary	O
operator	O
yourself	O
:	O
</s>
<s>
However	O
,	O
a	O
native	O
function	B-Application
composition	I-Application
operator	I-Application
was	O
introduced	O
in	O
Ruby	B-Language
2.6	O
:	O
</s>
<s>
directly	O
applied	O
function	B-Application
composition	I-Application
to	O
the	O
assemblage	O
of	O
building	O
blocks	O
known	O
as	O
'	O
monads	O
 '	O
in	O
the	O
Haskell	B-Language
programming	I-Language
language	I-Language
.	O
</s>
<s>
formally	O
defined	O
a	O
proof	O
rule	O
for	O
functional	B-Application
composition	I-Application
that	O
assures	O
a	O
program	O
's	O
safety	O
and	O
liveness	O
.	O
</s>
<s>
According	O
to	O
a	O
review	O
by	O
,	O
formal	O
treatment	O
of	O
composition	O
underlies	O
validation	O
of	O
component	O
assembly	O
in	O
visual	O
programming	O
languages	O
like	O
IBM	O
's	O
Visual	O
Age	O
for	O
the	O
Java	B-Language
language	I-Language
.	O
</s>
<s>
Pipelines	B-Operating_System
allowing	O
easy	O
composition	O
of	O
filters	B-Application
were	O
so	O
successful	O
that	O
they	O
became	O
a	O
design	B-Operating_System
pattern	I-Operating_System
of	O
operating	O
systems	O
.	O
</s>
<s>
Imperative	B-Application
procedures	I-Application
with	O
side	O
effects	O
violate	O
referential	O
transparency	O
and	O
therefore	O
are	O
not	O
cleanly	O
composable	O
.	O
</s>
