Re: List Struture Equality
Posted: Thu Mar 22, 2012 5:17 pm
The following assumes that for (sub)lists to be considered similar to each other, they must have the same number of elements.
Code: Select all
(define (similar-struct? obj1 obj2)
(cond
((and (atom? obj1) (atom? obj2))
#t )
((atom? obj1)
#f )
((atom? obj2)
#f)
(else
(and (similar-struct? (car obj1) (car obj2))
(similar-struct? (cdr obj1) (cdr obj2)) ))))