I need to develop a predicate in Prolog able to compare a list against fact. In other words, if the names of the products residing in the list are all in the database(fact) as well, then it gotta say "yes", otherwise "no". The predicate obviously receives a list of the products names. At the moment, I've got this piece of code.
domains
state = reduced ; normal
element = string
list = element*
database
producte (string, integer, state)
predicates
nondeterm check(list)
clauses
% ---> producte( description , price , state )
producte("Enciam",2,normal).
producte("Llet",1,reduced).
producte("Formatge",5,normal).
%unique case
check([Name]):-
producte([Name],_,_).
%general case
check([D|T]):-
producte(D,_,_),
check(T).
Goal
check(["Enciam","Llet","Formatge"]).
Your base case for check looks for the product's name as a list instead of as a string.