A lisp list in "dotted pair notation" looks something like this:
(1 . ()).
Since this is homework, I will let you bring it to its logical conclusion. Compare
(LIST 1 2) => (1 . (2 . ()))
from
(CONS 1 2) => (1 . 2).
How are these two different? How can you spot the difference using predicates?
Remember that all matching lisp lists end with an empty list. Ask yourself, how do you access the second element of the cons pair? The solution from there should be clear.
source share