我有一个prolog查询,需要一个数组作为原子:
searchEventsOnCategory(类别,事件) 类别是字符串列表。
示例输入: searchEventsOnCategory([ '酒吧', '迪斯科'],事件)
输出: Event = [listOfEvents]
searchEventsOnCategory(Categories,Events):-
findall([X,V], event(X,_,_,V), List),
compareCategories(List,Categories,Events1),
Events = Events1.
我的java代码是:
public ArrayList<String> getEventsByPrologWithCategories(ArrayList<String> Categories){
ArrayList<String> events = new ArrayList<String>();
//(Persons,Budget,Categories,Events)
Variable X = new Variable("X");
Compound V = new Compound("[Bar]");
Query q4 =
new Query(
"searchEventsOnCategory",
new Term[] {V,X}
);
...
return events;
}
我如何定义V,prolog将V作为字符串列表?
答案 0 :(得分:1)
您应该使用Term
而不是CompoundVariable X = new Variable("X");
Term t = Util.textToTerm("[Bar]");
Query q4 =
new Query(
"searchEventsOnCategory",
new Term[] {t,X}
);