<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
corecursion	B-Application
is	O
a	O
type	O
of	O
operation	O
that	O
is	O
dual	O
to	O
recursion	O
.	O
</s>
<s>
Whereas	O
recursion	O
works	O
analytically	O
,	O
starting	O
on	O
data	O
further	O
from	O
a	O
base	O
case	O
and	O
breaking	O
it	O
down	O
into	O
smaller	O
data	O
and	O
repeating	O
until	O
one	O
reaches	O
a	O
base	O
case	O
,	O
corecursion	B-Application
works	O
synthetically	O
,	O
starting	O
from	O
a	O
base	O
case	O
and	O
building	O
it	O
up	O
,	O
iteratively	O
producing	O
data	O
further	O
removed	O
from	O
a	O
base	O
case	O
.	O
</s>
<s>
Put	O
simply	O
,	O
corecursive	B-Application
algorithms	O
use	O
the	O
data	O
that	O
they	O
themselves	O
produce	O
,	O
bit	O
by	O
bit	O
,	O
as	O
they	O
become	O
available	O
,	O
and	O
needed	O
,	O
to	O
produce	O
further	O
bits	O
of	O
data	O
.	O
</s>
<s>
A	O
similar	O
but	O
distinct	O
concept	O
is	O
generative	O
recursion	O
which	O
may	O
lack	O
a	O
definite	O
"	O
direction	O
"	O
inherent	O
in	O
corecursion	B-Application
and	O
recursion	O
.	O
</s>
<s>
Where	O
recursion	O
allows	O
programs	O
to	O
operate	O
on	O
arbitrarily	O
complex	O
data	O
,	O
so	O
long	O
as	O
they	O
can	O
be	O
reduced	O
to	O
simple	O
data	O
(	O
base	O
cases	O
)	O
,	O
corecursion	B-Application
allows	O
programs	O
to	O
produce	O
arbitrarily	O
complex	O
and	O
potentially	O
infinite	O
data	B-General_Concept
structures	I-General_Concept
,	O
such	O
as	O
streams	O
,	O
so	O
long	O
as	O
it	O
can	O
be	O
produced	O
from	O
simple	O
data	O
(	O
base	O
cases	O
)	O
in	O
a	O
sequence	O
of	O
finite	O
steps	O
.	O
</s>
<s>
Where	O
recursion	O
may	O
not	O
terminate	O
,	O
never	O
reaching	O
a	O
base	O
state	O
,	O
corecursion	B-Application
starts	O
from	O
a	O
base	O
state	O
,	O
and	O
thus	O
produces	O
subsequent	O
steps	O
deterministically	O
,	O
though	O
it	O
may	O
proceed	O
indefinitely	O
(	O
and	O
thus	O
not	O
terminate	O
under	O
strict	O
evaluation	O
)	O
,	O
or	O
it	O
may	O
consume	O
more	O
than	O
it	O
produces	O
and	O
thus	O
become	O
non-productive	O
.	O
</s>
<s>
Many	O
functions	O
that	O
are	O
traditionally	O
analyzed	O
as	O
recursive	O
can	O
alternatively	O
,	O
and	O
arguably	O
more	O
naturally	O
,	O
be	O
interpreted	O
as	O
corecursive	B-Application
functions	O
that	O
are	O
terminated	O
at	O
a	O
given	O
stage	O
,	O
for	O
example	O
recurrence	O
relations	O
such	O
as	O
the	O
factorial	O
.	O
</s>
<s>
Corecursion	B-Application
can	O
produce	O
both	O
finite	O
and	O
infinite	O
data	B-General_Concept
structures	I-General_Concept
as	O
results	O
,	O
and	O
may	O
employ	O
self-referential	O
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
Corecursion	B-Application
is	O
often	O
used	O
in	O
conjunction	O
with	O
lazy	O
evaluation	O
,	O
to	O
produce	O
only	O
a	O
finite	O
subset	O
of	O
a	O
potentially	O
infinite	O
structure	O
(	O
rather	O
than	O
trying	O
to	O
produce	O
an	O
entire	O
infinite	O
structure	O
at	O
once	O
)	O
.	O
</s>
<s>
Corecursion	B-Application
is	O
a	O
particularly	O
important	O
concept	O
in	O
functional	B-Language
programming	I-Language
,	O
where	O
corecursion	B-Application
and	O
codata	O
allow	O
total	B-Application
languages	I-Application
to	O
work	O
with	O
infinite	O
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
Corecursion	B-Application
can	O
be	O
understood	O
by	O
contrast	O
with	O
recursion	O
,	O
which	O
is	O
more	O
familiar	O
.	O
</s>
<s>
While	O
corecursion	B-Application
is	O
primarily	O
of	O
interest	O
in	O
functional	B-Language
programming	I-Language
,	O
it	O
can	O
be	O
illustrated	O
using	O
imperative	O
programming	O
,	O
which	O
is	O
done	O
below	O
using	O
the	O
generator	O
facility	O
in	O
Python	O
.	O
</s>
<s>
In	O
these	O
examples	O
local	O
variables	O
are	O
used	O
,	O
and	O
assigned	O
values	O
imperatively	O
(	O
destructively	O
)	O
,	O
though	O
these	O
are	O
not	O
necessary	O
in	O
corecursion	B-Application
in	O
pure	O
functional	B-Language
programming	I-Language
.	O
</s>
<s>
In	O
pure	O
functional	B-Language
programming	I-Language
,	O
rather	O
than	O
assigning	O
to	O
local	O
variables	O
,	O
these	O
computed	O
values	O
form	O
an	O
invariable	O
sequence	O
,	O
and	O
prior	O
values	O
are	O
accessed	O
by	O
self-reference	O
(	O
later	O
values	O
in	O
the	O
sequence	O
reference	O
earlier	O
values	O
in	O
the	O
sequence	O
to	O
be	O
computed	O
)	O
.	O
</s>
<s>
Thus	O
a	O
call	B-General_Concept
stack	I-General_Concept
develops	O
in	O
the	O
process	O
.	O
</s>
<s>
For	O
example	O
,	O
to	O
compute	O
fac(3 )	O
,	O
this	O
recursively	O
calls	O
in	O
turn	O
fac(2 )	O
,	O
fac(1 )	O
,	O
fac(0 )	O
(	O
"	O
winding	O
up	O
"	O
the	O
stack	B-Application
)	O
,	O
at	O
which	O
point	O
recursion	O
terminates	O
with	O
fac(0 )	O
=	O
1	O
,	O
and	O
then	O
the	O
stack	B-Application
unwinds	O
in	O
reverse	O
order	O
and	O
the	O
results	O
are	O
calculated	O
on	O
the	O
way	O
back	O
along	O
the	O
call	B-General_Concept
stack	I-General_Concept
to	O
the	O
initial	O
call	O
frame	O
fac(3 )	O
that	O
uses	O
the	O
result	O
of	O
fac(2 )	O
=	O
2	O
to	O
calculate	O
the	O
final	O
result	O
as	O
3	O
×	O
2	O
=	O
3	O
×	O
fac(2 )	O
=	O
:	O
fac(3 )	O
and	O
finally	O
return	O
fac(3 )	O
=	O
6	O
.	O
</s>
<s>
This	O
stack	B-Application
unwinding	O
can	O
be	O
explicated	O
,	O
defining	O
the	O
factorial	O
corecursively	O
,	O
as	O
an	O
iterator	O
,	O
where	O
one	O
starts	O
with	O
the	O
case	O
of	O
,	O
then	O
from	O
this	O
starting	O
value	O
constructs	O
factorial	O
values	O
for	O
increasing	O
numbers	O
1	O
,	O
2	O
,	O
3	O
...	O
as	O
in	O
the	O
above	O
recursive	O
definition	O
with	O
"	O
time	O
arrow	O
"	O
reversed	O
,	O
as	O
it	O
were	O
,	O
by	O
reading	O
it	O
backwards	O
as	O
The	O
corecursive	B-Application
algorithm	O
thus	O
defined	O
produces	O
a	O
stream	B-Architecture
of	O
all	O
factorials	O
.	O
</s>
<s>
or	O
in	O
Haskell	B-Language
,	O
</s>
<s>
The	O
direct	O
output	O
of	O
the	O
corecursive	B-Application
function	O
does	O
not	O
simply	O
contain	O
the	O
factorial	O
values	O
,	O
but	O
also	O
includes	O
for	O
each	O
value	O
the	O
auxiliary	O
data	O
of	O
its	O
index	O
n	O
in	O
the	O
sequence	O
,	O
so	O
that	O
any	O
one	O
specific	O
result	O
can	O
be	O
selected	O
among	O
them	O
all	O
,	O
as	O
and	O
when	O
needed	O
.	O
</s>
<s>
There	O
is	O
a	O
connection	O
with	O
denotational	B-Application
semantics	I-Application
,	O
where	O
the	O
denotations	O
of	O
recursive	O
programs	O
is	O
built	O
up	O
corecursively	O
in	O
this	O
way	O
.	O
</s>
<s>
A	O
corresponding	O
corecursive	B-Application
generator	O
can	O
be	O
defined	O
as	O
:	O
</s>
<s>
This	O
generates	O
an	O
infinite	O
stream	B-Architecture
of	O
factorials	O
in	O
order	O
;	O
a	O
finite	O
portion	O
of	O
it	O
can	O
be	O
produced	O
by	O
:	O
</s>
<s>
As	O
can	O
be	O
readily	O
seen	O
here	O
,	O
this	O
is	O
practically	O
equivalent	O
(	O
just	O
by	O
substituting	O
return	O
for	O
the	O
only	O
yield	O
there	O
)	O
to	O
the	O
accumulator	O
argument	O
technique	O
for	O
tail	B-Language
recursion	I-Language
,	O
unwound	O
into	O
an	O
explicit	O
loop	O
.	O
</s>
<s>
Thus	O
it	O
can	O
be	O
said	O
that	O
the	O
concept	O
of	O
corecursion	B-Application
is	O
an	O
explication	O
of	O
the	O
embodiment	O
of	O
iterative	O
computation	O
processes	O
by	O
recursive	O
definitions	O
,	O
where	O
applicable	O
.	O
</s>
<s>
In	O
the	O
same	O
way	O
,	O
the	O
Fibonacci	B-Algorithm
sequence	I-Algorithm
can	O
be	O
represented	O
as	O
:	O
</s>
<s>
Because	O
the	O
Fibonacci	B-Algorithm
sequence	I-Algorithm
is	O
a	O
recurrence	O
relation	O
of	O
order	O
2	O
,	O
the	O
corecursive	B-Application
relation	O
must	O
track	O
two	O
successive	O
terms	O
,	O
with	O
the	O
corresponding	O
to	O
shift	O
forward	O
by	O
one	O
step	O
,	O
and	O
the	O
corresponding	O
to	O
computing	O
the	O
next	O
term	O
.	O
</s>
<s>
In	O
Haskell	B-Language
,	O
</s>
<s>
Tree	B-Algorithm
traversal	I-Algorithm
via	O
a	O
depth-first	B-Algorithm
approach	O
is	O
a	O
classic	O
example	O
of	O
recursion	O
.	O
</s>
<s>
Dually	O
,	O
breadth-first	B-Algorithm
traversal	I-Algorithm
can	O
very	O
naturally	O
be	O
implemented	O
via	O
corecursion	B-Application
.	O
</s>
<s>
Iteratively	O
,	O
one	O
may	O
traverse	O
a	O
tree	O
by	O
placing	O
its	O
root	O
node	O
in	O
a	O
data	B-General_Concept
structure	I-General_Concept
,	O
then	O
iterating	O
with	O
that	O
data	B-General_Concept
structure	I-General_Concept
while	O
it	O
is	O
non-empty	O
,	O
on	O
each	O
step	O
removing	O
the	O
first	O
node	O
from	O
it	O
and	O
placing	O
the	O
removed	O
node	O
's	O
child	O
nodes	O
back	O
into	O
that	O
data	B-General_Concept
structure	I-General_Concept
.	O
</s>
<s>
If	O
the	O
data	B-General_Concept
structure	I-General_Concept
is	O
a	O
stack	B-Application
(	O
LIFO	B-Application
)	O
,	O
this	O
yields	O
depth-first	B-Algorithm
traversal	I-Algorithm
,	O
and	O
if	O
the	O
data	B-General_Concept
structure	I-General_Concept
is	O
a	O
queue	B-Application
(	O
FIFO	O
)	O
,	O
this	O
yields	O
breadth-first	B-Algorithm
traversal	I-Algorithm
:	O
</s>
<s>
Using	O
recursion	O
,	O
a	O
depth-first	B-Algorithm
traversal	I-Algorithm
of	O
a	O
tree	O
is	O
implemented	O
simply	O
as	O
recursively	O
traversing	O
each	O
of	O
the	O
root	O
node	O
's	O
child	O
nodes	O
in	O
turn	O
.	O
</s>
<s>
The	O
call	B-General_Concept
stack	I-General_Concept
(	O
of	O
the	O
recursive	O
traversal	O
function	O
invocations	O
)	O
corresponds	O
to	O
the	O
stack	B-Application
that	O
would	O
be	O
iterated	O
over	O
with	O
the	O
explicit	O
LIFO	B-Application
structure	O
manipulation	O
mentioned	O
above	O
.	O
</s>
<s>
First	O
,	O
the	O
recursive	O
invocations	O
of	O
the	O
tree	B-Algorithm
traversal	I-Algorithm
functions	O
.	O
</s>
<s>
Recursive	O
,	O
bottom-up	O
output	O
creation	O
will	O
result	O
in	O
the	O
right-to-left	O
tree	B-Algorithm
traversal	I-Algorithm
.	O
</s>
<s>
A	O
breadth-first	B-Algorithm
traversal	I-Algorithm
creating	O
its	O
output	O
in	O
the	O
top-down	O
order	O
,	O
corecursively	O
,	O
can	O
be	O
also	O
implemented	O
by	O
starting	O
at	O
the	O
root	O
node	O
,	O
outputting	O
its	O
value	O
,	O
then	O
breadth-first	B-Algorithm
traversing	O
the	O
subtrees	O
–	O
i.e.	O
,	O
passing	O
on	O
the	O
whole	O
list	O
of	O
subtrees	O
to	O
the	O
next	O
step	O
(	O
not	O
a	O
single	O
subtree	O
,	O
as	O
in	O
the	O
recursive	O
approach	O
)	O
–	O
at	O
the	O
next	O
step	O
outputting	O
the	O
values	O
of	O
all	O
of	O
their	O
root	O
nodes	O
,	O
then	O
passing	O
on	O
their	O
child	O
subtrees	O
,	O
etc	O
.	O
</s>
<s>
In	O
this	O
case	O
the	O
generator	O
function	O
,	O
indeed	O
the	O
output	O
sequence	O
itself	O
,	O
acts	O
as	O
the	O
queue	B-Application
.	O
</s>
<s>
In	O
Haskell	B-Language
,	O
</s>
<s>
Notably	O
,	O
given	O
an	O
infinite	O
tree	O
,	O
the	O
corecursive	B-Application
breadth-first	B-Algorithm
traversal	I-Algorithm
will	O
traverse	O
all	O
nodes	O
,	O
just	O
as	O
for	O
a	O
finite	O
tree	O
,	O
while	O
the	O
recursive	O
depth-first	B-Algorithm
traversal	I-Algorithm
will	O
go	O
down	O
one	O
branch	O
and	O
not	O
traverse	O
all	O
nodes	O
,	O
and	O
indeed	O
if	O
traversing	O
post-order	O
,	O
as	O
in	O
this	O
example	O
(	O
or	O
in-order	O
)	O
,	O
it	O
will	O
visit	O
no	O
nodes	O
at	O
all	O
,	O
because	O
it	O
never	O
reaches	O
a	O
leaf	O
.	O
</s>
<s>
This	O
shows	O
the	O
usefulness	O
of	O
corecursion	B-Application
rather	O
than	O
recursion	O
for	O
dealing	O
with	O
infinite	O
data	B-General_Concept
structures	I-General_Concept
.	O
</s>
<s>
One	O
caveat	O
still	O
remains	O
for	O
trees	O
with	O
the	O
infinite	O
branching	B-Data_Structure
factor	I-Data_Structure
,	O
which	O
need	O
a	O
more	O
attentive	O
interlacing	O
to	O
explore	O
the	O
space	O
better	O
.	O
</s>
<s>
See	O
dovetailing	B-General_Concept
.	O
</s>
<s>
The	O
usual	O
post-order	O
depth-first	B-Algorithm
traversal	I-Algorithm
can	O
be	O
defined	O
as	O
:	O
</s>
<s>
This	O
can	O
then	O
be	O
called	O
by	O
df(t )	O
to	O
print	O
the	O
values	O
of	O
the	O
nodes	O
of	O
the	O
tree	O
in	O
post-order	O
depth-first	B-Algorithm
order	O
.	O
</s>
<s>
The	O
breadth-first	B-Algorithm
corecursive	B-Application
generator	O
can	O
be	O
defined	O
as	O
:	O
</s>
<s>
This	O
can	O
then	O
be	O
called	O
to	O
print	O
the	O
values	O
of	O
the	O
nodes	O
of	O
the	O
tree	O
in	O
breadth-first	B-Algorithm
order	O
:	O
</s>
<s>
On	O
the	O
other	O
hand	O
,	O
if	O
the	O
domain	O
of	O
discourse	O
is	O
the	O
category	O
of	O
complete	O
partial	O
orders	O
and	O
continuous	O
functions	O
,	O
which	O
corresponds	O
roughly	O
to	O
the	O
Haskell	B-Language
programming	I-Language
language	I-Language
,	O
then	O
final	O
types	O
coincide	O
with	O
initial	O
types	O
,	O
and	O
the	O
corresponding	O
final	O
coalgebra	O
and	O
initial	O
algebra	O
form	O
an	O
isomorphism	O
.	O
</s>
<s>
Corecursion	B-Application
is	O
then	O
a	O
technique	O
for	O
recursively	O
defining	O
functions	O
whose	O
range	O
(	O
codomain	O
)	O
is	O
a	O
final	O
data	O
type	O
,	O
dual	O
to	O
the	O
way	O
that	O
ordinary	O
recursion	O
recursively	O
defines	O
functions	O
whose	O
domain	O
is	O
an	O
initial	O
data	O
type	O
.	O
</s>
<s>
The	O
discussion	O
below	O
provides	O
several	O
examples	O
in	O
Haskell	B-Language
that	O
distinguish	O
corecursion	B-Application
.	O
</s>
<s>
Roughly	O
speaking	O
,	O
if	O
one	O
were	O
to	O
port	O
these	O
definitions	O
to	O
the	O
category	O
of	O
sets	O
,	O
they	O
would	O
still	O
be	O
corecursive	B-Application
.	O
</s>
<s>
This	O
informal	O
usage	O
is	O
consistent	O
with	O
existing	O
textbooks	O
about	O
Haskell	B-Language
.	O
</s>
<s>
The	O
examples	O
used	O
in	O
this	O
article	O
predate	O
the	O
attempts	O
to	O
define	O
corecursion	B-Application
and	O
explain	O
what	O
it	O
is	O
.	O
</s>
<s>
The	O
rule	O
for	O
primitive	O
corecursion	B-Application
on	O
codata	O
is	O
the	O
dual	O
to	O
that	O
for	O
primitive	B-Architecture
recursion	I-Architecture
on	O
data	O
.	O
</s>
<s>
Instead	O
of	O
descending	O
on	O
the	O
argument	O
by	O
pattern-matching	B-Language
on	O
its	O
constructors	O
(	O
that	O
were	O
called	O
up	O
before	O
,	O
somewhere	O
,	O
so	O
we	O
receive	O
a	O
ready-made	O
datum	O
and	O
get	O
at	O
its	O
constituent	O
sub-parts	O
,	O
i.e.	O
</s>
<s>
Thus	O
corecursion	B-Application
creates	O
(	O
potentially	O
infinite	O
)	O
codata	O
,	O
whereas	O
ordinary	O
recursion	O
analyses	O
(	O
necessarily	O
finite	O
)	O
data	O
.	O
</s>
<s>
Conversely	O
,	O
corecursion	B-Application
is	O
not	O
strictly	O
necessary	O
if	O
the	O
result	O
type	O
is	O
data	O
,	O
because	O
data	O
must	O
be	O
finite	O
.	O
</s>
<s>
where	O
primes	O
"	O
are	O
obtained	O
by	O
applying	O
the	O
primes	O
operation	O
to	O
the	O
stream	B-Architecture
(	O
Enu	O
2	O
)	O
"	O
.	O
</s>
<s>
or	O
in	O
Haskell	B-Language
,	O
</s>
<s>
if	O
called	O
with	O
10	O
..	O
as	O
the	O
initial	O
stream	B-Architecture
.	O
</s>
<s>
Here	O
is	O
another	O
example	O
in	O
Haskell	B-Language
.	O
</s>
<s>
The	O
following	O
definition	O
produces	O
the	O
list	O
of	O
Fibonacci	B-Algorithm
numbers	I-Algorithm
in	O
linear	O
time	O
:	O
</s>
<s>
This	O
feature	O
allows	O
algorithms	O
on	O
parts	O
of	O
codata	O
to	O
terminate	O
;	O
such	O
techniques	O
are	O
an	O
important	O
part	O
of	O
Haskell	B-Language
programming	I-Language
.	O
</s>
<s>
This	O
example	O
employs	O
a	O
self-referential	O
data	B-General_Concept
structure	I-General_Concept
.	O
</s>
<s>
Corecursion	B-Application
need	O
not	O
produce	O
an	O
infinite	O
object	O
;	O
a	O
corecursive	B-Application
queue	B-Application
is	O
a	O
particularly	O
good	O
example	O
of	O
this	O
phenomenon	O
.	O
</s>
<s>
The	O
following	O
definition	O
produces	O
a	O
breadth-first	B-Algorithm
traversal	I-Algorithm
of	O
a	O
binary	O
tree	O
in	O
the	O
top-down	O
manner	O
,	O
in	O
linear	O
time	O
(	O
already	O
incorporating	O
the	O
flattening	O
mentioned	O
above	O
)	O
:	O
</s>
<s>
This	O
list	O
serves	O
dual	O
purpose	O
as	O
both	O
the	O
input	O
queue	B-Application
and	O
the	O
result	O
(	O
gen	O
len	O
p	O
produces	O
its	O
output	O
len	O
notches	O
after	O
its	O
input	O
back-pointer	O
,	O
p	O
,	O
along	O
the	O
queue	B-Application
)	O
.	O
</s>
<s>
The	O
length	O
of	O
the	O
queue	B-Application
must	O
be	O
explicitly	O
tracked	O
in	O
order	O
to	O
ensure	O
termination	O
;	O
this	O
can	O
safely	O
be	O
elided	O
if	O
this	O
definition	O
is	O
applied	O
only	O
to	O
infinite	O
trees	O
.	O
</s>
<s>
This	O
Haskell	B-Language
code	O
uses	O
self-referential	O
data	B-General_Concept
structure	I-General_Concept
,	O
but	O
does	O
not	O
essentially	O
depend	O
on	O
lazy	O
evaluation	O
.	O
</s>
<s>
What	O
's	O
essential	O
is	O
the	O
ability	O
to	O
build	O
a	O
list	O
(	O
used	O
as	O
the	O
queue	B-Application
)	O
in	O
the	O
top-down	O
manner	O
.	O
</s>
<s>
For	O
that	O
,	O
Prolog	O
has	O
tail	B-Language
recursion	I-Language
modulo	O
cons	O
(	O
i.e.	O
</s>
<s>
Another	O
particularly	O
good	O
example	O
gives	O
a	O
solution	O
to	O
the	O
problem	O
of	O
breadth-first	B-Algorithm
labeling	O
.	O
</s>
<s>
This	O
solution	O
employs	O
a	O
self-referential	O
data	B-General_Concept
structure	I-General_Concept
,	O
and	O
the	O
binary	O
tree	O
can	O
be	O
finite	O
or	O
infinite	O
.	O
</s>
<s>
An	O
apomorphism	B-Application
(	O
such	O
as	O
an	O
anamorphism	B-Application
,	O
such	O
as	O
unfold	B-Application
)	O
is	O
a	O
form	O
of	O
corecursion	B-Application
in	O
the	O
same	O
way	O
that	O
a	O
paramorphism	B-Application
(	O
such	O
as	O
a	O
catamorphism	B-Application
,	O
such	O
as	O
fold	B-Application
)	O
is	O
a	O
form	O
of	O
recursion	O
.	O
</s>
<s>
The	O
Coq	B-Application
proof	I-Application
assistant	I-Application
supports	O
corecursion	B-Application
and	O
coinduction	B-Application
using	O
the	O
CoFixpoint	O
command	O
.	O
</s>
<s>
Corecursion	B-Application
,	O
referred	O
to	O
as	O
circular	O
programming	O
,	O
dates	O
at	O
least	O
to	O
,	O
who	O
credits	O
John	O
Hughes	O
and	O
Philip	O
Wadler	O
;	O
more	O
general	O
forms	O
were	O
developed	O
in	O
.	O
</s>
<s>
The	O
original	O
motivations	O
included	O
producing	O
more	O
efficient	O
algorithms	O
(	O
allowing	O
1	O
pass	O
over	O
data	O
in	O
some	O
cases	O
,	O
instead	O
of	O
requiring	O
multiple	O
passes	O
)	O
and	O
implementing	O
classical	O
data	B-General_Concept
structures	I-General_Concept
,	O
such	O
as	O
doubly	O
linked	O
lists	O
and	O
queues	B-Application
,	O
in	O
functional	B-Language
languages	I-Language
.	O
</s>
