I have a little problem with define facts and search in array in Prolog. I dont know, how add to rule my array and result of it.
Ok, need some like this:
% John is allergic to fish and milk.
isAllergic(john, [fish, milk]).
% food shark has allergen fish and john cant eat it and drink milk
allergen(shark, fish).
allergen(milk, milk).
%I need list of food, what person (john) can eat.
foodForPerson(F,C):- isAllergic(F, X), allergen(X,C).
And then I call FoodForPerson(john,X), but result is false. I think, that problem is in array. Result should be X=milk, X=shark.
element/2. Prolog already hasmember/2, e.g.,member(b, [a,b,c])is true. And per Boris' comment, read the documentation on how to ask a good question. You need to better describe specifically what you want your code to do and what it actually does. Showing examples helps. - lurkerisAllergic(john, [fish, milk])is true, how is it that john can drink milk, per your code comment? This code is very confusing. It's quite unclear what your facts and predicates really mean. - lurker