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.
- Code: Select all
>(car (cdr '(1 2)))
>(car (cdr '(1 . 2)))
error:2 is a value,etc...
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 use
something 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 cons
at 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 from
thanks a lot in advance.