On Thu, Nov 14, 2019 at 3:11 AM Andrew <ericpan...@gmail.com> wrote:

> 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))))))
>

I can't make sense of the last 2 lines. `(member x l)` returns a sublist of
l starting with x if l contains x, otherwise false. If your two calls to
`member` returns #f, then the next call to related? will compare (equal? #f
#f) and thus return #t, which is not what you want.

Furthermore, in your first call to `member`, the first argument you pass is
a list, which is suspicious.

To get a better sense of what is happening, a general advice  (works for
all programming languages) is to print the values of your variables, for
example:
(define (related? a1 a2)
  (displayln (list 'a1: a1 'a2: 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)))))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CABNTSaEzBFBF-OZZYo0c0sB4PLt87-qNZhs6z-tgLLo3abnOpg%40mail.gmail.com.

Reply via email to