ryu12341
04-06-2005, 01:34 AM
hey guys!!! im having trouble with scheme. the teacher gave us some sample code.
(define member?
(lambda (e S)
(cond ((null? S) #f)
((eq? e(car S)) #t)
(else return member? e(cdr S)))))
i just want to make sure im understanding this correctly. the function member takes in two lists e and S. if the list in S is empty it returns #f. if the first element in e is equal to the first element in S then it returns #t. then it returns the rest of the list in S. is this correct? for some reason i find scheme to be so tricky.
i also have another question. how do i call this function? i've tried
(member (1) (1 2 4 5))
(member '(1) (1 2 3 4))
i wanted to see if i could get this to output the #t and output the rest of the list in S but I only get a #f and a error message. thanks for the help guys!!!
(define member?
(lambda (e S)
(cond ((null? S) #f)
((eq? e(car S)) #t)
(else return member? e(cdr S)))))
i just want to make sure im understanding this correctly. the function member takes in two lists e and S. if the list in S is empty it returns #f. if the first element in e is equal to the first element in S then it returns #t. then it returns the rest of the list in S. is this correct? for some reason i find scheme to be so tricky.
i also have another question. how do i call this function? i've tried
(member (1) (1 2 4 5))
(member '(1) (1 2 3 4))
i wanted to see if i could get this to output the #t and output the rest of the list in S but I only get a #f and a error message. thanks for the help guys!!!