What do nested applications of cons construct improper lists?
I am learning scheme and confused about cons
. I came across this answer:
Cons element to list vs cons list to element in Scheme
I know when the second argument to cons
is a list , it adds the first argument to the head of the list
(cons 1 (list 2 3)
=>'(1 2 3)
The following pair makes sense to me:
(cons 2 3); 2.3 pair
However I don't understand why the following expression constructs an improper list
(cons 1 (cons 2 3))
=> '(1 2 . 3) ; an improper list
I just can't visualize what's going on with the expression above
can you please elaborate on that?