1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
//Construction de la liste
IntegerTerm terme = new IntegerTerm("2");
Term[] lesTermes = { new IntegerTerm("1"), new IntegerTerm("4")};
CompoundTerm listeDesTermes = new CompoundTerm(TermConstants.listTag, lesTermes);
//Construction de la question
Term[]argumentsQuestion = {terme,listeDesTermes};
CompoundTerm question = newCompoundTerm("member", argumentsQuestion);
//Execution de la question
// Execution d'une requête sans variable
Goal goal = interpreter.prepareGoal(question);
try {
int rc = interpreter.execute(goal);
System.out.println("Evaluation de "+question.toString()+" : "+rc);
if ((rc == PrologCode.SUCCESS) || (rc == PrologCode.SUCCESS_LAST)) {
return "yes";
}
} catch (PrologException e) {
e.printStackTrace();
}
return "no"; |
Partager