Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a Prolog program to solve the problem described above. Define a predicate

ID: 3705095 • Letter: W

Question

Write a Prolog program to solve the problem described above. Define a predicate satisfactory_meal(+Meal) whose parameter is a list of lists of the form [Dish_number, Has_meat?, Has_vegetables?, Organic?, Is_dessert?, Has_dairy?], where the Dish_number is a positive integer and the other list items are 1 or 0. The predicate should succeed if the meal is satisfactory, and fail otherwise.

You may assume that list Meal will be in the correct format when the predicate is called; you do not have to error-check for a non-list or an incorrectly formed list. The events in list Meal are not necessarily sorted by dish numbers or any other order. In your program, you may write and call any additional predicates that are helpful in the computation.

Examples:

should succeed,

should fail,

should fail, and

should fail.

Explanation / Answer

domains list=integer* predicates findnum(integer,list) clauses findnum(X,[]):- write(" Number Is Not Found"). findnum(X,[X|Tail]):- write(" Number Is Found"). findnum(X,[Y|Tail]):- findnum(X,Tail). OUT PUT ======= Goal: findnum(3,[1,2,3,4,5]) Number Is Found Yes ---------------------------- Goal: findnum(6,[1,2,3,4,5]) Number Is Not Found Yes ---------------------------- Goal: findnum(2,[1,2,2,1]) Number Is Found Yes

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote