<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
the	O
term	O
difference	B-Data_Structure
list	I-Data_Structure
refers	O
to	O
a	O
data	B-General_Concept
structure	I-General_Concept
representing	O
a	O
list	B-General_Concept
with	O
an	O
efficient	O
O(1 )	O
concatenation	O
operation	O
and	O
conversion	O
to	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
in	O
time	O
proportional	O
to	O
its	O
length	O
.	O
</s>
<s>
Difference	B-Data_Structure
lists	I-Data_Structure
can	O
be	O
implemented	O
using	O
first-class	O
functions	O
or	O
using	O
unification	O
.	O
</s>
<s>
Whether	O
a	O
difference	B-Data_Structure
list	I-Data_Structure
is	O
more	O
efficient	O
than	O
another	O
list	B-General_Concept
representations	O
depends	O
on	O
usage	O
patterns	O
.	O
</s>
<s>
If	O
an	O
algorithm	O
builds	O
a	O
list	B-General_Concept
by	O
concatenating	O
smaller	O
lists	O
,	O
which	O
are	O
themselves	O
built	O
by	O
concatenating	O
still	O
smaller	O
lists	O
,	O
then	O
use	O
of	O
difference	B-Data_Structure
lists	I-Data_Structure
can	O
improve	O
performance	O
by	O
effectively	O
"	O
flattening	O
"	O
the	O
list	B-General_Concept
building	O
computations	O
.	O
</s>
<s>
A	O
difference	B-Data_Structure
list	I-Data_Structure
f	O
is	O
a	O
single-argument	O
function	O
append	O
L	O
,	O
which	O
when	O
given	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
X	O
as	O
argument	O
,	O
returns	O
a	O
linked	B-Data_Structure
list	I-Data_Structure
containing	O
L	O
prepended	O
to	O
X	O
.	O
Concatenation	O
of	O
difference	B-Data_Structure
lists	I-Data_Structure
is	O
implemented	O
as	O
function	B-Application
composition	I-Application
.	O
</s>
<s>
This	O
implementation	O
is	O
typically	O
used	O
in	O
functional	B-Language
programming	I-Language
languages	I-Language
such	O
as	O
Haskell	B-Language
,	O
although	O
it	O
could	O
be	O
used	O
in	O
imperative	O
languages	O
as	O
well	O
.	O
</s>
<s>
As	O
functions	O
,	O
difference	B-Data_Structure
lists	I-Data_Structure
are	O
a	O
Cayley	O
representation	O
of	O
lists	O
as	O
monoids	O
,	O
or	O
more	O
specifically	O
their	O
transformation	O
monoid	O
induced	O
by	O
left	O
multiplication	O
.	O
</s>
<s>
Examples	O
of	O
use	O
are	O
in	O
the	O
ShowS	O
type	O
in	O
the	O
Prelude	O
of	O
Haskell	B-Language
,	O
and	O
in	O
Donald	O
Bruce	O
Stewart	O
's	O
.	O
</s>
<s>
Another	O
implementation	O
in	O
the	O
logic	B-Language
programming	I-Language
language	I-Language
Prolog	B-Language
uses	O
unification	O
variables	O
.	O
</s>
<s>
A	O
difference	B-Data_Structure
list	I-Data_Structure
is	O
a	O
pair	O
OpenList-Hole	O
,	O
where	O
the	O
first	O
element	O
OpenList	O
is	O
a	O
list	B-General_Concept
containing	O
an	O
unbound	O
unification	O
variable	O
(	O
hole	O
)	O
and	O
the	O
second	O
element	O
Hole	O
is	O
a	O
reference	O
to	O
the	O
hole	O
.	O
</s>
