Mercurial > repos > other > SevenLanguagesInSevenWeeks
diff 3-Prolog/day1-food.pl @ 51:178b18b4f9ba
Start experimenting with Prolog
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 25 Sep 2017 20:49:52 +0100 |
parents | |
children | cbaa3546f3f8 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/3-Prolog/day1-food.pl Mon Sep 25 20:49:52 2017 +0100 @@ -0,0 +1,19 @@ +% Define some foods and "flavours". +% Note that this is Americanised, so some of these definitions are generous! +food_type(velveeta, cheese). +food_type(ritz, cracker). +food_type(spam, meat). +food_type(sausage, meat). +food_type(jolt, soda). +food_type(twinkie, dessert). + +flavour(sweet, dessert). +flavour(savoury, meat). +flavour(savoury, cheese). +flavour(sweet, soda). + +food_flavour(X, Y) :- food_type(X, Z), flavour(Y, Z). +% Note: flavour(sweet, What) will return 'yes' and a closed set of answers because it is just all of the facts +% but "food_flavour(What, meat)" will return answers and then say 'no', because it hasn't been given a flavour() +% fact for "ritz"/"cracker". +% This doesn't explain why "food(What, meat)" returns "no" after spam and sausage, though. \ No newline at end of file