I've just started learning Racket and I have to check if an argument is a dotted pair.
I have tried this:
(pair? '(a . 1))
And returns #t
.
(pair? '('(a b c) . 1))
And returns #t
.
(pair? '(a b c))
And returns #t
. But I want to get #f in this case.
Is there another procedure like pair?
to get true only when I pass it as argument a dotted pair?
Maybe I will have to implement a procedure that check if it is not a list before I check if it is a pair.
UPDATE
I only need to check that '(a . 1)
is a dotted pair and any list is not a dotted pair.
(not (list? lst))
should do it – leppie'(1 2 . 3)
as well. I believe the author is looking for dotted pairs only. – merlyn(1 2 . 3)
is(1 . (2 . 3))
, a dotted pair. – molbdnilo