i am learning racket for my course and while going through solutions to an assignment, I found that a function doesn't return true, when comparing empty and '()
Here is the output I'm getting:
(lst-contains? '(1 2 3 ()) '()) ; output: #t
(lst-contains? '(1 2 3 ()) empty) ; output: #t
(lst-contains? '(1 2 3 empty) empty) ; output: #f (unexpected!)
(lst-contains? '(1 2 3 empty) '()) ; output: #f (unexpected!)
Here's my definition of lst-contains?
:
(define (lst-contains? lst element)
(cond
[(empty? lst) #f]
[(equal? (first lst) (element)) #t]
[else (lst-contains? (rest lst) element)]))
Thanks : )