Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Prolog,带键菜单的列表_Prolog - Fatal编程技术网

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).
它工作得很好,如果我花时间来解决它,很抱歉