hi all, trying to write a function nonlat? which returns true if the given list does not contain any atoms. so an empty list would be a nonlat and return true.
the tests i'm supposed to use are:
(nonlat? '(a b c))
(nonlat? '(a (b) (c)))
(nonlat? '((a b) ((c)) (d)))
(nonlat? '())
and the results are supposed to be #f, #f, #t and #t
i've managed to get this code but not sure how to get the third to turn out a #t instead of a #f. i've only gotten it down to this, pretty basic but a start
(define nonlat?
(lambda (list)
(null? list)))
second problem is to write a function member-cat? which returns true if the atom cat is a member of the given list, otherwise it returns false. it's also supposed to only take 1 argument which is the reason for the tests being like they are
the tests for this function is:
(member-cat? '())
(member-cat? '(bird cat dog))
(member-cat? '(hamster turtle))
(member-cat? '(cat))
and it should return #f, #t, #f, #t respectively. so far with the second function i've managed to get it to work for all but the second test, classmate says to use recursive call and hard code 'cat into it but not sure exactly how to do that
(define member-cat?
(lambda (lat)
(cond
((null? lat) #f)
(else (or (eq? 'cat (car lat)))))))