Prolog rule - need help getting something to work?

I want to write a rule in the prolog, which basically says that if user X did not pay the amount of Y within 7 days, then he will evaluate the value of payment_outstanding (X).

so far i have something like this:

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

owes_money(bob, 500, 0, 3).            //bob borrowed 500 on day 3

the rule works, but the problem is that part of days + 7, for example, in the system, if someone borrowed on the 3rd day, then the offer will never evaluate to true, and the days will always be 3, how can I to implement? Do I need to write a separate rule? I hope you understand what I'm trying to say.

thank

+3
source share
1 answer

, . owes_money(bob, 500, 0, 3). , bob , .

: get_time(-Time). :

convert_time(+Time, -String)
convert_time(+Time, -Year, -Month, -Day, -Hour, -Minute, -Second, -MilliSeconds)

, , .

- owes_money :

owes_money(bob, 500, 0, 2010, 3, 10). %2010 for the year, 3 for the month  ... 

:

get_time(X), convert_time(X, CurrYear, CurrMonth, CurrDay, _, _, _, _).%CurrYear will give you current year, etc ... . You don't need the hour minutes etc .. that why are the _

CurrYear, CurrMonth CurrDay , owes_money, , .

, !

+1

Source: https://habr.com/ru/post/1736105/


All Articles