(define (related? a1 a2)
(if (equal? a1 a2)
true
(related? (member (rest ("proc that calls list" a1)) (rest ("proc that calls list" a2)))
(member a1 ("proc that calls list" a2))))))
a1 and a2 are part of a binary search tree and I have another function that creates a list from the elements of the tree
hence the "proc that calls list"
For some reason, whatever input I'm putting into a1 and a2 is returning only true, even when I know the answer is suppose to be false
Can anyone guide me onto what's going wrong?
(eq? (list) (list))But if I'm understanding your code correctly, it seems like it would not work for lists of different lengths.
=> #t
(for*/or ([x (in-list list-1)] [y (in-list list-2)]) (equal? x y))
Alternatively, since duplicated elements don't matter, you can check the intersection:
(not (set-empty? (set-intersect list-1 list-2)))
I have this:
(define (related? a1 a2)
(if (equal? a1 a2)
true
(related? (member (rest ("proc that calls list" a1)) (rest ("proc that calls list" a2)))
(member a1 ("proc that calls list" a2))))))