开发者

Question about prolog

I am trying to create some rules and facts on a certain situation. The situation is such that if a user owes money then he is said to be in debt after 5 days if it is not repaid, if he doesn't then he is a normal person. So far i'm experimenting with something like:

I have two rules:

debtpayment_unfulfilled(X) :- owes_money(W开发者_开发知识库, Amountowed, Amountpaid, Days), Days >= 7,Amountowed > Amountpaid. .
debtpayment_fulfilled(X) :- debt_paid(W,Amountowed,Amountpaid), Amountowed =:= Amountpaid.
owes_money(jim, 500, 200, 8).

But i can't seem to get it to compile, XSB tells me there is an unbound variable expr in clause #1...

any ideas? edit scrap that, I have just got it to compile lol, typo, btw does the ruling look right for what im trying to do? when i try running it, i cant get an answer with the query:

debtpayment_unfulfilled(jim).

edit:

is it possible to do something like this:

debtpayment_unfulfilled(X) :- owes_money(X, Amountowed, Amountpaid, Days), Days >= Days + 7,Amountowed > Amountpaid.

the days + 7 bit or is that not possible?


Your mistake is that you use different variable names in debtpayment_unfulfilled and owes_money. Try this:

debtpayment_unfulfilled(X) :- owes_money(X, Amountowed, Amountpaid, Days), Days >= 7,Amountowed > Amountpaid.
debtpayment_fulfilled(X) :- debt_paid(X, Amountowed, Amountpaid), Amountowed =:= Amountpaid.
owes_money(jim, 500, 200, 8).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜