# (lispref.info)Dotted Pair Notation

Next: Association List Type Up: List Type
```
Dotted Pair Notation
....................

"Dotted pair notation" is an alternative syntax for cons cells that
represents the CAR and CDR explicitly.  In this syntax, `(A . B)'
stands for a cons cell whose CAR is the object A, and whose CDR is the
object B.  Dotted pair notation is therefore more general than list
syntax.  In the dotted pair notation, the list `(1 2 3)' is written as
`(1 .  (2 . (3 . nil)))'.  For `nil'-terminated lists, the two
notations produce the same result, but list notation is usually clearer
and more convenient when it is applicable.  When printing a list, the
dotted pair notation is only used if the CDR of a cell is not a list.

Box notation can also be used to illustrate what dotted pairs look
like.  For example, `(rose . violet)' is diagrammed as follows:

___ ___
|___|___|--> violet
|
|
--> rose

Dotted pair notation can be combined with list notation to represent
a chain of cons cells with a non-`nil' final CDR.  For example, `(rose
violet . buttercup)' is equivalent to `(rose . (violet . buttercup))'.
The object looks like this:

___ ___      ___ ___
|___|___|--> |___|___|--> buttercup
|            |
|            |
--> rose     --> violet

These diagrams make it evident that `(rose . violet . buttercup)'
must have an invalid syntax since it would require that a cons cell
have three parts rather than two.

The list `(rose violet)' is equivalent to `(rose . (violet))' and
looks like this:

___ ___      ___ ___
|___|___|--> |___|___|--> nil
|            |
|            |
--> rose     --> violet

Similarly, the three-element list `(rose violet buttercup)' is
equivalent to `(rose . (violet . (buttercup)))'.

It looks like this:

___ ___      ___ ___      ___ ___
|___|___|--> |___|___|--> |___|___|--> nil
|            |            |
|            |            |
--> rose     --> violet   --> buttercup

```

automatically generated by info2www