public static void main(String[] args) { YProlog engine = new YProlog(); engine.consult("append([],L,L)."); engine.consult("append([A|B],L,[A|Tail]) :- append(B,L,Tail)."); // String query = "append(X,[c],[a,n(J),cs])" ; String query = "asserta(a(1))"; String value = engine.queryToString(query); if (value != null) log.debug(value.toString()); String[] result = engine.queryToTable(query); if (result != null) for (int i = 0; i < result.length; i++) log.debug("Result " + i + ":" + result[i]); Vector results = engine.queryToTable(query, 0, true); if (results != null) for (int i = 0; i < results.size(); i++) { log.debug("Results " + i); result = (String[]) results.elementAt(i); for (int j = 0; j < result.length; j++) log.debug("Result" + j + ": " + result[j]); } }
public boolean execute(String query) throws InferenceEngineException { checkEngine(); String result = _engine.queryToString(query); if (result == null) return false; else return true; }