2
votes

Given that I have entered the following facts into the factbase. Each sidedish has two ingredients:

maindish(thanksgiving, turkey). 
sidedish(thanksgiving,pie). 
ingredient(pie,spice).
ingredient(pie,sugar). 

I have written the following rule to return the dishes for a given holiday:

meal(Holiday, [F1,F2]) :- maindish(Holiday,F1), sidedish(Holiday,F2).

?- meal(thanksgiving, Foods).

I am trying to write a rule called ingredientList that will identify the type of ingredients needed for each holiday. By associating the dishes and ingredients for each given holiday.

1
Please get informed how this site works by reading the tour.false

1 Answers

1
votes
ingredientlist(Holiday, Ingredients) :-
   setof(Ingredient,
          Dishes^Dish^ ( meal(Holiday,Dishes),
                         member(Dish, Dishes),
                         ingredient(Dish, Ingredient) ),
         Ingredients).