use of org.skife.jdbi.v2.Query in project packages-jpl by SWI-Prolog.
the class Test method test_7.
static void test_7() {
System.out.print("test 7...");
String t7 = "r(f(X,X), Y)";
Variable vX = new Variable("X");
Variable vY = new Variable("Y");
Query q7 = new Query("r", new Term[] { new Compound("f", new Term[] { vX, vX }), vY });
Map<String, Term>[] solutions = q7.allSolutions();
if (solutions.length != 2) {
System.out.println(t7 + " failed:");
System.out.println("\tExpected: 2 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
Term X = solutions[0].get("X");
Term Y = solutions[0].get("Y");
if (X != Y) {
System.out.println(t7 + " failed:");
System.out.println(Util.toString(solutions[0]));
System.out.println("\tThe variables to which X and Y are bound in the first solution should be identical.");
// System.exit(1);
}
X = solutions[1].get("X");
Y = solutions[1].get("Y");
if (X == Y) {
System.out.println(t7 + " failed:");
System.out.println(Util.toString(solutions[1]));
System.out.println("\tThe variables to which X and Y are bound in the second solution should be distinct.");
// System.exit(1);
}
if (X.equals(Y)) {
System.out.println(t7 + " failed:");
System.out.println(Util.toString(solutions[1]));
System.out.println("\tThe variables to which X and Y are bound in the second solution should not be \"equal\".");
// System.exit(1);
}
System.out.println("passed");
}
use of org.skife.jdbi.v2.Query in project packages-jpl by SWI-Prolog.
the class TestGC method main.
public static void main(String[] argv) {
int max;
Query.hasSolution("consult('test.pl')");
if (argv.length > 0)
max = Integer.parseInt(argv[0]);
else
max = 10;
System.out.println(max + " iterations");
for (int i = 0; i < max; i++) {
Query q = new Query("testpred", new Term[] { new Atom("a" + i) });
q.oneSolution();
}
Query.hasSolution("stats");
}
use of org.skife.jdbi.v2.Query in project packages-jpl by SWI-Prolog.
the class Time method test_3.
static void test_3() {
Variable Y = new Variable("Y");
Query query = new Query("noop_nobind", new Term[] { tree, Y });
System.out.print("noop_nobind");
for (int i = 0; i < num_trials; ++i) {
timer.start();
query.hasSolution();
timer.stop();
data[3][i] = timer.getElapsedTimeInMillis();
System.out.print(".");
}
System.out.println("done");
}
use of org.skife.jdbi.v2.Query in project packages-jpl by SWI-Prolog.
the class Time method test_1.
static void test_1() {
Query query = new Query("traverse", new Term[] { tree });
System.out.print("traverse");
for (int i = 0; i < num_trials; ++i) {
timer.start();
query.hasSolution();
timer.stop();
data[1][i] = timer.getElapsedTimeInMillis();
System.out.print(".");
}
System.out.println("done");
}
use of org.skife.jdbi.v2.Query in project packages-jpl by SWI-Prolog.
the class FetchLongList method main.
public static void main(String[] args) {
// Prolog.set_default_init_args(new String[] { "libpl.dll", "-f",
// "D:/pcm/bin/pcm.ini", "-g", "pcm_2000" });
Term t = (Term) ((new Query("findall(foo(N,bar),between(1,2308,N),L)")).oneSolution().get("L"));
int i = 0;
while (t.hasFunctor(".", 2)) {
t = t.arg(2);
i = i + 1;
}
System.err.println("got a list of " + i + " members");
}
Aggregations