I am trying to write my own 'list?' predicate in scheme. I know that definition of a list: 1. en empty list 2. pair, whose cdr is a pair
I know my code is wrong because it is returning true value on every pair, but every pair is not a list. I do not know how to implement the condition that cdr of the list must be also a pair.
(define (my-list? x)
(if (equal? x ()) #t
(pair? x)))
list?
" Your example didn't check the cdr so you need to do that when argument is a pair. – Sylwester