<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
anonymous	B-Language
recursion	I-Language
is	O
recursion	O
which	O
does	O
not	O
explicitly	O
call	O
a	O
function	O
by	O
name	O
.	O
</s>
<s>
This	B-Application
can	O
be	O
done	O
either	O
explicitly	O
,	O
by	O
using	O
a	O
higher-order	B-Language
function	I-Language
–	O
passing	O
in	O
a	O
function	O
as	O
an	O
argument	O
and	O
calling	O
it	O
–	O
or	O
implicitly	O
,	O
via	O
reflection	B-Language
features	O
which	O
allow	O
one	O
to	O
access	O
certain	O
functions	O
depending	O
on	O
the	O
current	O
context	O
,	O
especially	O
"	O
the	O
current	O
function	O
"	O
or	O
sometimes	O
"	O
the	O
calling	O
function	O
of	O
the	O
current	O
function	O
"	O
.	O
</s>
<s>
In	O
programming	O
practice	O
,	O
anonymous	B-Language
recursion	I-Language
is	O
notably	O
used	O
in	O
JavaScript	B-Language
,	O
which	O
provides	O
reflection	B-Language
facilities	O
to	O
support	O
it	O
.	O
</s>
<s>
In	O
general	O
programming	O
practice	O
,	O
however	O
,	O
this	B-Application
is	O
considered	O
poor	O
style	O
,	O
and	O
recursion	O
with	O
named	O
functions	O
is	O
suggested	O
instead	O
.	O
</s>
<s>
Anonymous	B-Language
recursion	I-Language
via	O
explicitly	O
passing	O
functions	O
as	O
arguments	O
is	O
possible	O
in	O
any	O
language	O
that	O
supports	O
functions	O
as	O
arguments	O
,	O
though	O
this	B-Application
is	O
rarely	O
used	O
in	O
practice	O
,	O
as	O
it	O
is	O
longer	O
and	O
less	O
clear	O
than	O
explicitly	O
recursing	O
by	O
name	O
.	O
</s>
<s>
In	O
theoretical	O
computer	B-General_Concept
science	I-General_Concept
,	O
anonymous	B-Language
recursion	I-Language
is	O
important	O
,	O
as	O
it	O
shows	O
that	O
one	O
can	O
implement	O
recursion	O
without	O
requiring	O
named	O
functions	O
.	O
</s>
<s>
This	B-Application
is	O
particularly	O
important	O
for	O
the	O
lambda	B-Language
calculus	I-Language
,	O
which	O
has	O
anonymous	O
unary	O
functions	O
,	O
but	O
is	O
able	O
to	O
compute	O
any	O
recursive	O
function	O
.	O
</s>
<s>
This	B-Application
anonymous	B-Language
recursion	I-Language
can	O
be	O
produced	O
generically	O
via	O
fixed-point	B-Application
combinators	I-Application
.	O
</s>
<s>
Anonymous	B-Language
recursion	I-Language
is	O
primarily	O
of	O
use	O
in	O
allowing	O
recursion	O
for	O
anonymous	B-General_Concept
functions	I-General_Concept
,	O
particularly	O
when	O
they	O
form	O
closures	B-Language
or	O
are	O
used	O
as	O
callbacks	O
,	O
to	O
avoid	O
having	O
to	O
bind	O
the	O
name	O
of	O
the	O
function	O
.	O
</s>
<s>
Anonymous	B-Language
recursion	I-Language
primarily	O
consists	O
of	O
calling	O
"	O
the	O
current	O
function	O
"	O
,	O
which	O
results	O
in	O
direct	B-Algorithm
recursion	I-Algorithm
.	O
</s>
<s>
Anonymous	O
indirect	B-Algorithm
recursion	I-Algorithm
is	O
possible	O
,	O
such	O
as	O
by	O
calling	O
"	O
the	O
caller	O
(	O
the	O
previous	O
function	O
)	O
"	O
,	O
or	O
,	O
more	O
rarely	O
,	O
by	O
going	O
further	O
up	O
the	O
call	B-General_Concept
stack	I-General_Concept
,	O
and	O
this	B-Application
can	O
be	O
chained	O
to	O
produce	O
mutual	B-Algorithm
recursion	I-Algorithm
.	O
</s>
<s>
The	O
self-reference	O
of	O
"	O
the	O
current	O
function	O
"	O
is	O
a	O
functional	O
equivalent	O
of	O
the	O
"	O
this	B-Application
"	O
keyword	O
in	O
object-oriented	B-Language
programming	I-Language
,	O
allowing	O
one	O
to	O
refer	O
to	O
the	O
current	O
context	O
.	O
</s>
<s>
Anonymous	B-Language
recursion	I-Language
can	O
also	O
be	O
used	O
for	O
named	O
functions	O
,	O
rather	O
that	O
calling	O
them	O
by	O
name	O
,	O
say	O
to	O
specify	O
that	O
one	O
is	O
recursing	O
on	O
the	O
current	O
function	O
,	O
or	O
to	O
allow	O
one	O
to	O
rename	O
the	O
function	O
without	O
needing	O
to	O
change	O
the	O
name	O
where	O
it	O
calls	O
itself	O
.	O
</s>
<s>
However	O
,	O
as	O
a	O
matter	O
of	O
programming	B-Language
style	I-Language
this	B-Application
is	O
generally	O
not	O
done	O
.	O
</s>
<s>
Given	O
an	O
anonymous	B-General_Concept
function	I-General_Concept
,	O
this	B-Application
can	O
be	O
done	O
either	O
by	O
binding	O
a	O
name	O
to	O
the	O
function	O
,	O
as	O
in	O
named	O
function	O
expressions	O
in	O
JavaScript	B-Language
,	O
or	O
by	O
assigning	O
the	O
function	O
to	O
a	O
variable	O
and	O
then	O
calling	O
the	O
variable	O
,	O
as	O
in	O
function	O
statements	O
in	O
JavaScript	B-Language
.	O
</s>
<s>
Since	O
languages	O
that	O
allow	O
anonymous	B-General_Concept
functions	I-General_Concept
generally	O
allow	O
assigning	O
these	O
functions	O
to	O
variables	O
(	O
if	O
not	O
first-class	O
functions	O
)	O
,	O
many	O
languages	O
do	O
not	O
provide	O
a	O
way	O
to	O
refer	O
to	O
the	O
function	O
itself	O
,	O
and	O
explicitly	O
reject	O
anonymous	B-Language
recursion	I-Language
;	O
examples	O
include	O
Go	B-Application
.	O
</s>
<s>
For	O
example	O
,	O
in	O
JavaScript	B-Language
the	O
factorial	O
function	O
can	O
be	O
defined	O
via	O
anonymous	B-Language
recursion	I-Language
as	O
such	O
:	O
</s>
<s>
Even	O
without	O
mechanisms	O
to	O
refer	O
to	O
the	O
current	O
function	O
or	O
calling	O
function	O
,	O
anonymous	B-Language
recursion	I-Language
is	O
possible	O
in	O
a	O
language	O
that	O
allows	O
functions	O
as	O
arguments	O
.	O
</s>
<s>
This	B-Application
is	O
done	O
by	O
adding	O
another	O
parameter	O
to	O
the	O
basic	O
recursive	O
function	O
and	O
using	O
this	B-Application
parameter	O
as	O
the	O
function	O
for	O
the	O
recursive	O
call	O
.	O
</s>
<s>
This	B-Application
creates	O
a	O
higher-order	B-Language
function	I-Language
,	O
and	O
passing	O
this	B-Application
higher	O
function	O
itself	O
allows	O
anonymous	B-Language
recursion	I-Language
within	O
the	O
actual	O
recursive	O
function	O
.	O
</s>
<s>
This	B-Application
can	O
be	O
done	O
purely	O
anonymously	O
by	O
applying	O
a	O
fixed-point	B-Application
combinator	I-Application
to	O
this	B-Application
higher	B-Language
order	I-Language
function	I-Language
.	O
</s>
<s>
This	B-Application
is	O
mainly	O
of	O
academic	O
interest	O
,	O
particularly	O
to	O
show	O
that	O
the	O
lambda	B-Language
calculus	I-Language
has	O
recursion	O
,	O
as	O
the	O
resulting	O
expression	O
is	O
significantly	O
more	O
complicated	O
than	O
the	O
original	O
named	O
recursive	O
function	O
.	O
</s>
<s>
Conversely	O
,	O
the	O
use	O
of	O
fixed-pointed	O
combinators	B-Application
may	O
be	O
generically	O
referred	O
to	O
as	O
"	O
anonymous	B-Language
recursion	I-Language
"	O
,	O
as	O
this	B-Application
is	O
a	O
notable	O
use	O
of	O
them	O
,	O
though	O
they	O
have	O
other	O
applications	O
.	O
</s>
<s>
This	B-Application
is	O
illustrated	O
below	O
using	O
Python	O
.	O
</s>
<s>
Using	O
a	O
higher-order	B-Language
function	I-Language
so	O
the	O
top-level	O
function	O
recurses	O
anonymously	O
on	O
an	O
argument	O
,	O
but	O
still	O
needing	O
the	O
standard	O
recursive	O
function	O
as	O
an	O
argument	O
:	O
</s>
<s>
The	O
second	O
line	O
can	O
be	O
replaced	O
by	O
a	O
generic	O
higher-order	B-Language
function	I-Language
called	O
a	O
combinator	B-Application
:	O
</s>
<s>
In	O
the	O
lambda	B-Language
calculus	I-Language
,	O
which	O
only	O
uses	O
functions	O
of	O
a	O
single	O
variable	O
,	O
this	B-Application
can	O
be	O
done	O
via	O
the	O
Y	B-Application
combinator	I-Application
.	O
</s>
<s>
First	O
make	O
the	O
higher-order	B-Language
function	I-Language
of	O
two	O
variables	O
be	O
a	O
function	O
of	O
a	O
single	O
variable	O
,	O
which	O
directly	O
returns	O
a	O
function	O
,	O
by	O
currying	B-Application
:	O
</s>
<s>
There	O
are	O
two	O
"	O
applying	O
a	O
higher	B-Language
order	I-Language
function	I-Language
to	O
itself	O
"	O
operations	O
here	O
:	O
f(f )	O
in	O
the	O
first	O
line	O
and	O
fact1(fact1 )	O
in	O
the	O
second	O
.	O
</s>
<s>
Factoring	O
out	O
the	O
second	O
double	O
application	O
into	O
a	O
combinator	B-Application
yields	O
:	O
</s>
<s>
Combining	O
the	O
two	O
combinators	B-Application
into	O
one	O
yields	O
the	O
Y	B-Application
combinator	I-Application
:	O
</s>
<s>
Expanding	O
out	O
the	O
Y	B-Application
combinator	I-Application
yields	O
:	O
</s>
<s>
Combining	O
these	O
yields	O
a	O
recursive	O
definition	O
of	O
the	O
factorial	O
in	O
lambda	B-Language
calculus	I-Language
(	O
anonymous	B-General_Concept
functions	I-General_Concept
of	O
a	O
single	O
variable	O
)	O
:	O
</s>
<s>
In	O
APL	B-Language
,	O
the	O
current	O
dfn	B-Application
is	O
accessible	O
via	O
∇	O
.	O
</s>
<s>
This	B-Application
allows	O
anonymous	B-Language
recursion	I-Language
,	O
such	O
as	O
in	O
this	B-Application
implementation	O
of	O
the	O
factorial	O
:	O
</s>
<s>
In	O
JavaScript	B-Language
,	O
the	O
current	O
function	O
is	O
accessible	O
via	O
arguments.callee	O
,	O
while	O
the	O
calling	O
function	O
is	O
accessible	O
via	O
arguments.caller	O
.	O
</s>
<s>
These	O
allow	O
anonymous	B-Language
recursion	I-Language
,	O
such	O
as	O
in	O
this	B-Application
implementation	O
of	O
the	O
factorial	O
:	O
</s>
<s>
Starting	O
with	O
Perl	B-Language
5.16	O
,	O
the	O
current	O
subroutine	O
is	O
accessible	O
via	O
the	O
__SUB__	O
token	O
,	O
which	O
returns	O
a	O
reference	O
to	O
the	O
current	O
subroutine	O
,	O
or	O
undef	O
outside	O
a	O
subroutine	O
.	O
</s>
<s>
This	B-Application
allows	O
anonymous	B-Language
recursion	I-Language
,	O
such	O
as	O
in	O
the	O
following	O
implementation	O
of	O
the	O
factorial	O
:	O
</s>
<s>
In	O
R	B-Language
,	O
the	O
current	O
function	O
can	O
be	O
called	O
using	O
Recall	O
.	O
</s>
<s>
lapply	O
,	O
inside	O
the	O
anonymous	B-General_Concept
function	I-General_Concept
definition	O
.	O
</s>
<s>
In	O
this	B-Application
case	O
,	O
sys.function(0 )	O
can	O
be	O
used	O
.	O
</s>
