...
Make sure this page is shown at the right time.
Retrieve the following information by putting the appropriate predicates in the places indicated in the rule by comments and by using the variable names indicated below.
We need to retrieve the chosen recipe from memory. Find the necessary predicate and name that variable Recipe.
The previous step retrieves the Recipe ID, but we also need the recipe name. Use a variable called Name for this.
Retrieve the time needed to complete the recipe in a variable named Minutes.
Retrieve the number of servings in a variable called Persons.
To retrieve a list of the recipe steps and a list of ingredients, you will need to implement two additional predicates in
recipe_selection.pl
. The predicates that we need to implement can be found in therecipe_selection.pl
file and are labeled with the comment%For Visual Support to-do
This first is a rule that returns a list of ingredients
ingredients(RecipeID, IngredientList) :-
Find a built-in Prolog predicate (part of the Prolog language) that you can use for returning a set of ingredients that fit match a specific goal (i.e. the recipe we are looking at). This predicate should take (a list, check elements in the list for compliance with a condition (goal of filtering), then return a list of the elements that comply). When you find the predicate be sure to read what arguments it takes in the Prolog documentation. You can Google or look here https://www.swi-prolog.org/.
In the database find the predicate that is used to store ingredient information.
Now that we have found the necessary predicate we need to define the “goal”, i.e. the condition an ingredient has to fulfill to be added to the set. We only want ingredients for a recipe with a certain RecipeID. In the database find the predicate that is used to store ingredient information. With this ingredient information predicate we will define our condition in our set predicate For this rule ingredients use the function from above and to simplify your goal We will use the predicate in Step 3(a)(i) to retrieve a set of ingredients(list without repetition). We want to output a list of ingredients(List) by inputting all available ingredient information(Information) where the inputted recipe ID(RecipeID) and Information match with the arguments in a predicate with ingredient information found in the database. Those that match should be returned in a List which is outputted by the rule as IngredientList.
To simplify the condition you can use the caret(^) in Prolog by defining your goal/ condition in the set predicate with the following syntax:
RecipeID^(
...
databaseIngredientPredicate(RecipeID, inputted Information variable to be filtered))
Find another built-in Prolog predicate to retrieve a list of the recipe steps without changing their order. There is no repetition, so this predicate does not need to remove duplicates (as in the previous step).
Your rule for retrieving the steps needs to use the accompanying rule
getStepString
in your goal of the built-in Prolog predicate, so your goal should look as follows:RecipeID^getStepString(RecipeID, Step)
.Go back to html.pl and to a50recipeConfirm
Save the recipe steps as Steps
Save the list of ingredients as Ingredients
Figure out a way to add the recipe picture to this page wherever you would like. You will have to look around or at some bootstrap documentation to complete this step.
...