ryu12341
05-03-2005, 02:49 AM
Hi guys!!! I got another question for ya. I have 2 functions defined, one called subset? and set-equal?. here is some code for them.
(define subset?
(lambda (e r)
(cond ((null? e) #t)
((member? (car e) r)
(subset? (cdr e) r))
(else #f))))
(define set-equal?
(lambda (i o)
(cond ((and (subset? i o) (subset? o i)) #t)
(else #f))))
I've been messing around with scheme and was reading about mutual recursion. How would I implement mutual recursion between these 2 functions? Say I have a test case where I call:
(set-equal? '(a(b(c d))) '(((d c) b) a)) should return t, and
(set-equal? '(a(b(c d))) '((d c b) a))) should return f.
I'm not sure what modifications I need to make to my 2 functions I've defined above to get this kind of result. Any help would be greatly appreciated!! Thanks!!!
(define subset?
(lambda (e r)
(cond ((null? e) #t)
((member? (car e) r)
(subset? (cdr e) r))
(else #f))))
(define set-equal?
(lambda (i o)
(cond ((and (subset? i o) (subset? o i)) #t)
(else #f))))
I've been messing around with scheme and was reading about mutual recursion. How would I implement mutual recursion between these 2 functions? Say I have a test case where I call:
(set-equal? '(a(b(c d))) '(((d c) b) a)) should return t, and
(set-equal? '(a(b(c d))) '((d c b) a))) should return f.
I'm not sure what modifications I need to make to my 2 functions I've defined above to get this kind of result. Any help would be greatly appreciated!! Thanks!!!