Although .
can be a part of a symbol, .
is not in itself a valid symbol. .
is used in list structure as a divider between the car
and the cdr
. eg. (a . (b . (c . ()))) ; ==> (a b c)
.
Practical application is the historic use as a rest argument in the prototype of a procedure and you can use it as template an transformation of macros. Also, read
can read it in and you can use it as data like (define lst '((a) . (b)))
.
So to recap:
(a . b)
is a pair of a
and b
, while (a.b)
is the same as (a.b . ())
thus a pair of the symbol a.b
and the empty list.
As for how to create a pair you use cons
. (cons 'a 'b) => (a . b)
while (list a b) => (cons 'a (cons b '()))
. Now you can make a pair with two lists as arguments, (cons '(1 4) '(2 5))
but if you print it you know that (a . (b))
is the same as (a b)
thus (cons '(1 4) '(2 5))
will display as ((1 4) 2 5)
since it will prefer not to display the dot. If it would prefer to show dots it would have displayed it as ((1 . (4 . ())) . ((2 . (5 . ()))))
instead since thats how many pairs there are in that data structure.
If you have managed to get the output ((1 4) (2 5))
and really wanted ((1 . 4) (2 . 5))
you need to replace a list
with cons
.