...
In the diet rule, we need to find all the ingredients that a certain recipe has and then input them into a new function we shall create below diet, called ‘ingredientsMeetDiet’. This function should return a diet should work if the list of ingredients that fit of the inputted RecipeID fits the dietary restriction . This list should be returned with the name inputted DietaryRestriction.
Code Block |
---|
ingredientsMeetDiet([ Ingredient | Rest ], DietaryRestriction) :- |
The ingredientsMeetDiet predicate is our stop clause, which should take a list of ingredients and check if each one meets a dietary restriction. It has a stop clause that is in the file already and will recursively check each ingredient and return ‘false’ when an ingredient does not meet the given dietary restriction. The predicate ‘typeIngredient’ can be used to check if an ingredient meets a dietary restriction. Fill in the body of the rule for ingredientsMeetDiet.
...
Predicate Description | Rule Head | Notes/Instructions |
---|---|---|
The predicate to filter recipes on cuisines (e.g., Italian recipes) | applyFilter('cuisine', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes that meet the dietary restrictions (such as ‘vegetarian’). | applyFilter('dietaryrestriction', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the max amount of time | applyFilter('duration', Minutes, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter easy recipes | applyFilter('easykeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient | applyFilter('excludeingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on the exclusion of a specific ingredient type (for example: ‘beef’) | applyFilter('excludeingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicates to filter recipes on a specific ingredient inclusion | applyFilter('ingredient', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter by including an ingredient type | applyFilter('ingredienttype', Ingredient, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on meal type (for example: breakfast) | applyFilter('mealType', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of ingredients | applyFilter('nrOfIngredients', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a maximum number of steps | applyFilter('nrSteps', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes and return fast recipes. A recipe is fast if it takes less than 30 minutes | applyFilter('shorttimekeyword', _, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter on the number of servings | applyFilter('servings', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
Predicate to filter recipes on a tag (for example: pizza) | applyFilter('tag', Value, RecipeIDsIn, RecipeIDsOut) :- |
|
...