Tuesday, 15 April 2014

date - Prolog: Why does it not use negative values in arithmetic? -



date - Prolog: Why does it not use negative values in arithmetic? -

the code below used calculate difference between 2 dates.

timediff(id, days, months, years) :- book_in(id, date(y1, m1, d1)), book_due(id, date(y2, m2, d2)), days d1-d2, months m1-m2, years y1-y2.

however, purposes handle negative numbers, instance, if book submitted have negative value indicate returned before due date, , positive value indicate overdue. there different way express or have prolog handle negative values?

my bad, turns out sample values in code cause of confusion: give 'incorrect' value

date math time prolog difference

No comments:

Post a Comment