Exemple #1
0
  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]);
      }
  }
Exemple #2
0
 public void insert(String clause) throws InferenceEngineException {
   checkEngine();
   _engine.consult(clause + ".");
   // _engine.query("assert(" + clause + ")") ;
 }