Hi guys!i'm a total noob at lisp,so please excuse me if you find those questions dumb:i conclude from the code below that '(1 . 2) just makes one single cons with its car pointing to 1 and its cdr pointing to 2,while '(1 2) will create a list of two cons,with their car respectively pointing to 1 and 2.

so my first question is:what is the real difference beetween '(1 2) and '(1 . 2),and if my conclusion is correct,why would anyone want to usesomething like '(1 . 2)...is it something like a tuple?

and now about the second question:well it's about what (cons 4 lst) does.i know that it returns a new list,but is the list returned a deep or shallow copy of the first one with an additional consat its begining?in other words,does (cons 4 lst) just make a new cons with a car pointing to 4 an a cdr pointing to (car lst),or does it make a new list fromscratch?thanks a lot in advance.

The_Ash wrote:what is the real difference beetween '(1 2) and '(1 . 2),and if my conclusion is correct,why would anyone want to usesomething like '(1 . 2)...is it something like a tuple?

The difference is as you said: the former is two conses and the latter is a single one. Every cons cell requires a little bookkeeping, and the pointer to NIL object which terminates a proper list also consumes memory. In the past this could have been possibly relevant, for modern systems the difference doesn't really matter. The only real common use for dot syntax is for destructuring, where it can signify the tail of the list.

The_Ash wrote:well it's about what (cons 4 lst) does.

CONS constructs a new cons cell, which points to the arguments of the function. That is the only thing it does, and in particular it doesn't copy anything.

Beside what was already said: usually there would be functions of a pattern c[ad]+r that perform what you did by sequentially calling car and cdr.

In other words: cadr is the same as calling car, then cdr, cddr is the same as calling cdr then cdr, caar is the same as calling car, then car and so on. I think it depends on the particular variant of Lisp you are using, but there would be usually at least 4 levels. See here for more info: http://www.lispworks.com/documentation/ ... _car_c.htm