Prolog,带键菜单的列表
早上好!我想解决这个问题,我迷路了。 我有这些数据Prolog,带键菜单的列表,prolog,Prolog,早上好!我想解决这个问题,我迷路了。 我有这些数据 ing(salt). ing(egg). ing(oil). ing(water). food(pa, [salt,egg,oil]). food(he, [salt,egg,water]). 例如,如果给定的配料如下:[盐,油],那么我如何找到食物?因此结果必须是食物>>“pa” 比如: foodOf([salt,oil]):- ... //must return the food in general not only the *str
ing(salt).
ing(egg).
ing(oil).
ing(water).
food(pa, [salt,egg,oil]).
food(he, [salt,egg,water]).
例如,如果给定的配料如下:[盐,油],那么我如何找到食物?因此结果必须是食物>>“pa”
比如:
foodOf([salt,oil]):- ...
//must return the food in general not only the *string* 'pa'
我解决了
list(E,[E|_]).
list(E,[_|L]) :- list(E,L).
inclus([],_).
inclus([E|L1],L2):-list(E,L2),inclus(L1,L2).
foodof(F,X):- food(F,Y),inclus(X,Y).
它工作得很好,如果我花时间来解决它,很抱歉