thank you very much。
--------------------------------------------------------------------------------



------------------ 原始邮件 ------------------




 
 发件人: Sean Charles <[email protected]>;
 

 
 发送时间: 2013-10-12 22:42:20
 

 
 收件人: liubin0314 <[email protected]>; 
 

 
 抄送: Users-prolog<[email protected]>; 
 

 
 主题: Re: how to get some statements about a constant?
 





 On 12 Oct 2013, at 14:02, liubin0314 <[email protected]> wrote:

 
 such as:KB
 is:aunt(gugu,wo).father(baba,wo).does prolog can
 get the answer to X(baba,wo) which is father(baba,wo)?
 and x(Y,wo)?
 
 

 No.

 
 
 yes

 
 | ?- listing.

 
 
 

 
 aunt(gugu, wo).

 
 father(baba, wo).

 
 
 

 
 yes

 
 | ?- X(baba,wo).

 
 uncaught
 exception: error(syntax_error('user_input:4 (char:2) . or
 operator expected after expression'),read_term/3)

 
 | ?- x(Y,wo).

 
 uncaught
 exception: error(existence_error(procedure,x/2),top_level/0)

 
 | ?- 

 It's actually not a bad question, at least not to me because I
 can't answer it as well as I'd like. I have been using Prolog in
 earnest for about five months every day and I think I know what I
 am doing but a question like this can catch you out!

 
 

 Your first question about "X(baba,wo)" shows that you
 may not have grasped the way you ask questions of Prolog in
 general which is fine if you are just starting out. If you want
 facts that state who is the father you should (as you have) have this:

 
 

 
     father(baba, wo).

 
 

 but then you would phrase the question like this:

 
 

 
     father(baba, X).

 
 

 I hope now you can begin to see that you are thinking "the
 wrong way around" at least when it comes to expressing your
 facts about whom is the father of who. That question will cause
 prolog to scan the database for facts that match and there is only one.

 
 

 Hope that helps.

 Sean.

 
 

 
 

 
 

 
 




_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to