use of org.jpl7.Integer in project packages-jpl by SWI-Prolog.
the class FamilyMT method run.
public void run() {
Map<String, Term> solution;
// Variable X = new Variable("X");
//
Query q2 = new Query("child_of(joe,ralf)");
System.err.println("child_of(joe,ralf) is " + (q2.hasSolution() ? "provable" : "not provable"));
new Query("sleep(?)", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
//
Query q3 = new Query("descendent_of(steve,ralf)");
System.err.println("descendent_of(steve,ralf) is " + (q3.hasSolution() ? "provable" : "not provable"));
delay();
//
Query q4 = new Query("descendent_of(X, ralf)");
solution = q4.oneSolution();
System.err.println("first solution of descendent_of(X, ralf)");
System.err.println("X = " + solution.get("X"));
delay();
//
Map<String, Term>[] solutions = q4.allSolutions();
System.err.println("all solutions of descendent_of(X, ralf)");
for (int i = 0; i < solutions.length; i++) {
System.err.println("X = " + solutions[i].get("X"));
}
delay();
//
System.err.println("each solution of descendent_of(X, ralf)");
while (q4.hasMoreSolutions()) {
solution = q4.nextSolution();
System.err.println("X = " + solution.get("X"));
}
delay();
//
Query q5 = new Query("descendent_of(X, Y)");
System.err.println(id + ": each solution of descendent_of(X, Y)");
while (q5.hasMoreSolutions()) {
solution = q5.nextSolution();
System.err.println(id + ": X = " + solution.get("X") + ", Y = " + solution.get("Y"));
delay();
}
}
use of org.jpl7.Integer in project packages-jpl by SWI-Prolog.
the class TestJUnit method testBigInteger1.
public void testBigInteger1() {
BigInteger a = new BigInteger(Long.toString(51L));
// 51**51, too big for a long
BigInteger b = a.pow(51);
Term x = Query.oneSolution("X is 51**51").get("X");
assertTrue("X is an org.jpl7.Integer", x.isInteger());
// System.out.println("X.bigValue() = " + x.bigValue().toString());
// System.out.println("b.bigValue() = " + b.toString());
assertTrue("X is a big integer", x.isBigInteger());
assertTrue("X's big value is 51**51", x.bigValue().equals(b));
}
use of org.jpl7.Integer in project packages-jpl by SWI-Prolog.
the class TestJUnit method testIntegerFromByte1.
public void testIntegerFromByte1() {
// -128..127
byte b = (byte) 127;
Integer i = new Integer(b);
assertTrue(i.intValue() == b);
}
use of org.jpl7.Integer 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.jpl7.Integer in project packages-jpl by SWI-Prolog.
the class TestOLD method test10l.
private static void test10l() {
Query q5 = new Query(new Compound("length", new Term[] { new Variable("Zs"), new org.jpl7.Integer(5) }));
Map<String, Term> s5 = q5.oneSolution();
System.err.println("test10l:");
System.err.println(" length(Zs,5)");
System.err.println(" " + Util.toString(s5));
System.err.println(" Zs = " + (Term) s5.get("Zs"));
System.err.println();
}
Aggregations