Home

dottedpair

A dotted pair, in the Lisp family of languages, is a simple two-element data structure formed from a cons cell. It consists of a car (the first element) and a cdr (the second element) and is written in dot notation as (car . cdr). The dot signals that the cdr is not a list.

In Lisp, a proper list is built from cons cells whose cdr so far forms another list

Printing conventions vary by context. Lists print without dots, while dotted pairs print with the explicit

Uses and significance: Dotted pairs are the fundamental building blocks of lists and more general pair-based

or
nil.
For
example,
(a
b
c)
is
equivalent
to
(a
.
(b
.
(c
.
nil))).
A
dotted
pair
such
as
(a
.
b)
has
a
non-list
cdr,
and
prints
with
the
dot:
(a
.
b).
If
the
cdr
is
nil,
the
pair
is
a
single
element
list
like
(a)
which
is
treated
as
(a
.
nil)
and
prints
without
the
dot.
dot,
reflecting
the
underlying
pair
structure.
The
functions
cons,
car,
and
cdr
operate
on
these
constructs;
for
instance,
(cons
'a
'b)
yields
(a
.
b),
while
(cons
'a
'(b
c))
yields
(a
b
c).
data
structures.
They
are
used
to
represent
association
lists
(key
.
value),
to
build
trees,
graphs,
or
other
structures
where
a
simple
two-element
linkage
is
needed.
The
concept
is
central
to
Lisp,
Scheme,
and
related
languages,
where
every
list
is
ultimately
a
chain
of
such
pairs
ending
in
nil,
and
dotted
notation
remains
a
common
way
to
express
non-list
cdrs.