Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 8, Exercise 1: case of director & cast for the same movie not handled #24

Open
cobalamin opened this issue Mar 28, 2015 · 1 comment

Comments

@cobalamin
Copy link

In Chapter 8, Exercise 1, the suggested solution is as follows:

[[(friends ?p1 ?p2)
  [?m :movie/cast ?p1]
  [?m :movie/cast ?p2]
  [(not= ?p1 ?p2)]]
 [(friends ?p1 ?p2) [?m :movie/cast ?p1] [?m :movie/director ?p2]]
 [(friends ?p1 ?p2) (friends ?p2 ?p1)]]

I think the second rule definition should also have an inequality clause for ?p1 and ?p2, and read

[(friends ?p1 ?p2)
  [?m :movie/cast ?p1]
  [?m :movie/director ?p2]
  [(not= ?p1 ?p1)]]

Which certainly looks more verbose and doesn't fit on the same line in the exercise editor anymore, but it handles a previously unhandled case: When a director is also cast in their own movie (which doesn't seem to exist in this db, but generally isn't that unlikely).

Perhaps I'm missing something and the first rule definition already prevents this?

@jonase
Copy link
Owner

jonase commented Mar 28, 2015

You're correct. PR welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants