Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Experimenting with Recipes in Prolog
recipe(muffin).
recipe('chickpea soup').
recipe(tiramisu).
recipe(pancakes).
recipe(latkes).
recipe(gazpacho).
contains(blueberries, muffin).
contains(milk, muffin).
contains(butter, muffin).
contains(eggs, muffin).
contains(salt, muffin).
contains(sugar, muffin).
contains(flour, muffin).
contains('baking powder', muffin).
contains(cloves, 'chickpea soup').
contains(onions, 'chickpea soup').
contains(chickpeas, 'chickpea soup').
contains(rosemary, 'chickpea soup').
contains(garlic, 'chickpea soup').
contains('bay leaves', 'chickpea soup').
contains(salt, 'chickpea soup').
contains(tomatoes, 'chickpea soup').
contains(carrots, 'chickpea soup').
contains(celery, 'chickpea soup').
contains(lemon, 'chickpea soup').
contains(pepper, 'chickpea soup').
contains('mascarpone cheese', tiramisu).
contains(eggs, tiramisu).
contains(sugar, tiramisu).
contains(coffee, tiramisu).
contains('lady finger cookies', tiramisu).
contains(flour, pancakes).
contains('baking powder',pancakes).
contains(salt, pancakes).
contains(sugar, pancakes).
contains(eggs, pancakes).
contains(milk, pancakes).
contains(butter, pancakes).
contains(potatoes, latkes).
contains(onion, laktes).
contains(eggs, latkes).
contains(flour, latkes).
contains(salt, latkes).
contains('baking powder', latkes).
contains(pepper, latkes).
contains(oil, latkes).
contains(tomatoes, gazpacho).
contains('green pepper', gazpacho).
contains(cucumber, gazpacho).
contains(garlic, gazpacho).
contains(vinegar, gazpacho).
contains(oil, gazpacho).
diet(vegetarian, muffin).
diet(nut-free, muffin).
diet(nut-free, 'chickpea soup').
diet(vegetarian, 'chickpea soup').
diet(vegan, 'chickpea soup').
diet('diary free', 'chickpea soup').
diet('egg free', 'chickpea soup').
diet(vegetarian, tiramisu).
diet(nut-free, tiramisu).
diet(vegetarian, pancakes).
diet(nut-free, pancakes).
diet(vegetarian, latkes).
diet(nut-free, latkes).
diet('diary free', latkes).
diet(nut-free, gazpacho).
diet(vegetarian, gazpacho).
diet(vegan, gazpacho).
diet('diary free', gazpacho).
diet('egg free', gazpacho).
minutes_to_prepare(60, muffin).
minutes_to_prepare(120, 'chickpea soup').
minutes_to_prepare(120, tiramisu).
minutes_to_prepare(30, pancakes).
minutes_to_prepare(45, latkes).
minutes_to_prepare(30, gazpacho).
meal(breakfast, muffin).
meal(snack, muffin).
meal(dessert, muffin).
meal(lunch, 'chickpea soup').
meal(dinner, 'chickpea soup').
meal(dessert, tiramisu).
meal(breakfast, pancakes).
meal(breakfast, latkes).
meal(appetizer, gazpacho).
flavor(sweet, muffin).
flavor(savory, 'chickpea soup').
flavor(sweet, tiramisu).
flavor(sweet, pancakes).
flavor(savory, latkes).
flavor(savory, gazpacho).
list_ingredients(Y) :-
contains(X, Y),
write(X),
nl,
fail.
list_recipes(X) :-
contains(X, Y),
write(Y),
nl,
fail.
contains_ingredients(X, []):-
recipe(X).
contains_ingredients(X, [H|T]):-
contains(H, X), contains_ingredients(X, T).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.