Search code examples
lispquotecons

Lisp, cons and (number . number) difference


What is the difference between

(cons 2  3)

and

'(2 . 3)

in Lisp?


Solution

  • '(2 . 3) is a dotted pair.

    (cons 2 3) creates a dotted pair too. So these should evaluate to the same thing.

    So one is a literal for a dotted pair, the other one creates a dotted pair.