use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.
the class Zahed method main.
public static void main(java.lang.String[] argv) {
System.out.println("starting...");
Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
Query q1 = new Query(goal1);
if (!q1.hasSolution()) {
System.out.println("consult('zahed.pl') failed");
return;
}
Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
Compound list1 = new Compound(".", new Term[] { t1, list2 });
Variable answer = new Variable("A");
Compound goal2 = new Compound("gen", new Term[] { list1, answer });
Query q2 = new Query(goal2);
Map<String, Term> solution = q2.oneSolution();
if (solution == null) {
System.out.println("failed");
} else {
System.out.println(solution.get("A").toString());
}
System.out.println("finished");
}
use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.
the class Family method main.
public static void main(String[] argv) {
Query q1 = new Query("consult", new Term[] { new Atom("jpl/test/family.pl") });
System.err.println("consult " + (q1.hasSolution() ? "succeeded" : "failed"));
for (int i = 0; i < 20; i++) {
System.out.println("spawning client[" + i + "]");
new Family(i).start();
}
}
use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.
the class TestJUnit method testHasMoreSolutions1.
public void testHasMoreSolutions1() {
StringBuffer sb = new StringBuffer();
Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
Map<String, Term> soln;
q.open();
while (q.hasMoreSolutions()) {
soln = q.nextSolution();
sb.append(((Atom) soln.get("C")).name());
}
q.close();
assertEquals("Query#hasMoreSolutions() + Query#nextSolution() work as intended", "prolog", sb.toString());
}
use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.
the class TestJUnit method testJRef1.
public void testJRef1() {
int i = 76543;
Integer I = new Integer(i);
Query q = new Query("jpl_call(?,intValue,[],I2)", new Term[] { Term.objectToJRef(I) });
Term I2 = q.oneSolution().get("I2");
assertTrue(I2.isInteger() && I2.intValue() == i);
}
use of org.hypertrace.entity.data.service.v1.Query in project packages-jpl by SWI-Prolog.
the class TestJUnit method suite.
public static junit.framework.Test suite() {
if (syntax.equals("traditional")) {
JPL.setTraditional();
Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "--traditional", "-q", "--home=../..", "--nosignals" });
} else {
Prolog.set_default_init_args(new String[] { "swipl.dll", "-x", startup, "-f", "none", "-g", "true", "-q", "--home=../..", "--nosignals" });
}
assertTrue((new Query("consult", new Term[] { new Atom(test_jpl) })).hasSolution());
assertTrue((new Query("use_module(library(jpl))")).hasSolution());
return new TestSuite(TestJUnit.class);
}
Aggregations