NHans
NHans

Reputation: 63

What is the function definition for member?

(define (member atom list)
  (cond
    ((null? list) '())
    (= atom (car list) "True")
      (else
      (member atom(cdr list)))
    )
 )

(member '5 '(1 2 3 4 5))

Always it gives true even though that atom isn't a member in the list. Could you plz help me to clarify this question as soon as possible.

Upvotes: 0

Views: 243

Answers (1)

Vijay Mathew
Vijay Mathew

Reputation: 27184

The second clause of cond should be:

((= atom (car list)) "True")

Upvotes: 2

Related Questions