Question: Can you solve this using prolog please ! Assume the presence of the days relation that describes how many days are in each calendar month

 Can you solve this using prolog please! Assume the presence of

Can you solve this using prolog please!

Assume the presence of the days relation that describes how many days are in each calendar month of a non-leap year. days (1, 31). days (2, 28). days (3, 31). days (4, 30). days (5, 31). days (6, 30). days (7, 31). days (8, 31). days (9, 30). days (10, 31). Days (11, 30). days (12, 31). The structure dat (M, D) describes a date. For example dat (7, 4) would denote the 4^th July. Write the relation diff (From, To, N), where N is the number of days between starting date From and finishing date To. The From date is not included in the count. For example: ?- diff (dat (2, 1), dat (2, 2), N). N = 1. ?- diff (dat (1, 1), dat (3, 10), N). N = 68. If the day or month values in a date are invalid (e.g. dat (4, 31), dat (13, 1) then the value of N returned should be -1. If the From date is later than To then the -1 error value should also be returned for N

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!