On Mar 2, 2013, at 5:07 AM, Michael Situ wrote: > Hi, > > I think I found a typo in the example from section 17.8 and wanted to bring > it to the authors' attention: > > (define (web=? a-wp another-wp) > (cond > [(empty? a-wp) (empty? another-wp)] > [(symbol? (first a-wp)) > (and (and (cons? another-wp) (symbol? (first another-wp))) > (and (symbol=? (first a-wp) (first another-wp)) > (web=? (rest a-wp) (rest another-wp))))] > [else > (and (and (cons? another-wp) (list? (first another-wp))) > (and (web=? (first a-wp) (first another-wp)) > (web=? (rest a-wp) (rest another-wp))))])) > > should the list? function call be cons? instead?
When evaluation reaches the third case, we know that a-wp is (cons ewp a-wp0) The only way that another-wp is possibly equal to a-wp means (1) another-wp must have the shape (cons e-another-wp another-wp0) (2) which means that e-another-wp must belong to "Web page" To ensure condition 2 e-another-wp (as much as needed at this point), e-another-wp must be one of (a) empty (b) (cons some-symbol web-page) (c) (cons embedded-web-page web-page) At a min, it must be either empty or cons. That means it must be list? not just cons? . Makes sense? -- Matthias
____________________ Racket Users list: http://lists.racket-lang.org/users

