Lists and Dotted Pairs

[1]> '(a.b)
(A.B)   ; this is an atom whose name contains a dot.

[2]> '(a . b)  ; this is a dotted pair expressed using the infix dot operator .
(A . B)

[3]> '(a . nil) ; dotting an object with nil produces a list.
(A)

[4]> '(a . (b c)) ; every list is a dotted pair whose second element is a list.
(A B C)

[5]> '(a . (b . c)) ; not every dotted pair is a (true) list.
(A B . C)

[6]> (LENGTH '(a . (b c)))
3

[7]> (LENGTH '(a . (b . c)))

*** - LENGTH: A true list must not end with C
. . . 


[8]> (CONS  'a 'b) ; but every dotted pair is a CONS.
(A . B) 

[9]> (FIRST '(a . (b . c))) 
A

[10]> (REST '(a . (b . c)))
(B . C)

[11]> (REST '(a . b))
B

[12]> (REST '(a b))
(B)


Last Updated: July18, 2005