This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

Whats with the dot notation?

3 posts · 6728 views

Can someone please explain me what is the dot notation in lists:
(first . second)
Why not just:
(first second)
Thanks!

Re: Whats with the dot notation?

See http://www.gigamonkeys.com/book/they-ca ... ssing.html

It's a Common Lisp book, not an Emacs Lisp book, but I think the concepts more or less apply. Basically (a . b) is called a cons cell -- a is the "car" and b is the "cdr". The cdr tends to be a pointer to another cons cell, making a list. That is, if b is a pointer to (c . d) and d is a pointer to (e . nil), you get (a . (c . (e . nil))), which can be displayed in list form as (a c e). The simple graphics in the link above really help for visualizing what's going on.

Re: Whats with the dot notation?

(cons 'first 'second)  ==> (first . second)
(cons 'first (list second)) ==> (first second)
Need an online wiki database? My Lisp startup http://www.formlis.com combines a wiki with forms and reports.