use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test method test_4.
static void test_4() {
System.out.print("test 4...");
Variable X = new Variable("X");
Query q4 = new Query("p", new Term[] { X });
Term[] target = new Term[] { a, f_a, pair_a_b, new Variable("_") };
Map<String, Term>[] solutions = q4.allSolutions();
if (solutions.length != 4) {
System.out.println("p(X) failed:");
System.out.println("\tExpected: 4 solutions");
System.out.println("\tGot: " + solutions.length);
// System.exit(1);
}
for (int i = 0; i < solutions.length - 1; ++i) {
Term binding = solutions[i].get("X");
if (!binding.equals(target[i])) {
System.out.println("p(X) failed");
System.out.println("\tExpected: " + target[i]);
System.out.println("\tGot: " + binding);
// System.exit(1);
}
}
System.out.println("passed");
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test_Report method reportConfiguration.
@Test
public void reportConfiguration() {
System.out.println("\t JPL testing under the following configuration:");
// Query.hasSolution("use_module(library(jpl))"); // only because we call e.g. jpl_pl_syntax/1 below
useJPLmodule();
Term swi = Query.oneSolution("current_prolog_flag(version_data,Swi)").get("Swi");
System.out.println("\t swipl.version = " + swi.arg(1) + "." + swi.arg(2) + "." + swi.arg(3));
// This is the problematic one as it wil trigger loading library(jpl)
System.out.println("\t swipl.syntax = " + Query.oneSolution("jpl_pl_syntax(Syntax)").get("Syntax"));
System.out.println("\t swipl.home = " + Query.oneSolution("current_prolog_flag(home,Home)").get("Home").name());
System.out.println("\t jpl.jar = " + JPL.version_string());
System.out.println("\t jpl.dll = " + org.jpl7.fli.Prolog.get_c_lib_version());
System.out.println("\t jpl.pl = " + Query.oneSolution("jpl_pl_lib_version(V)").get("V").name());
System.out.println("\t java.version = " + System.getProperty("java.version"));
System.out.println("\t java_lib_version = " + JPL.version_string());
System.out.println("\t c_lib_version = " + org.jpl7.fli.Prolog.get_c_lib_version());
System.out.println("\t pl_lib_version = " + Query.oneSolution("jpl:jpl_pl_lib_version(V)").get("V").name() + " " + Query.oneSolution("module_property(jpl, file(F))").get("F").name());
System.out.println("\t os.name = " + System.getProperty("os.name"));
System.out.println("\t os.arch = " + System.getProperty("os.arch"));
System.out.println("\t os.version = " + System.getProperty("os.version"));
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Test_String method testStringXput2.
@Test
public void testStringXput2() {
String s1 = "\u0000\u007F\u0080\u00FF";
String s2 = "\u0100\u7FFF\u8000\uFFFF";
// concatenate in Java
String s = s1 + s2;
// concatenate
Term a = Query.oneSolution("string_concat(?,?,S)", new Term[] { new Atom(s1), new Atom(s2) }).get("S");
// in
// Prolog
assertEquals(s, a.name());
assertEquals("string", a.atomType());
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Family method run.
public void run() {
Map<String, Term> solution;
Variable X = new Variable("X");
// --------------------------------------------------
Query q2 = new Query("child_of", new Term[] { new Atom("joe"), new Atom("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", new Term[] { new Atom("steve"), new Atom("ralf") });
System.err.println("descendent_of(steve,ralf) is " + (q3.hasSolution() ? "provable" : "not provable"));
new Query("sleep", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
// --------------------------------------------------
Query q4 = new Query("descendent_of", new Term[] { X, new Atom("ralf") });
solution = q4.oneSolution();
System.err.println("first solution of descendent_of(X, ralf)");
System.err.println("X = " + solution.get(X.name));
new Query("sleep", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
// --------------------------------------------------
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.name));
}
new Query("sleep", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
// --------------------------------------------------
System.err.println("each solution of descendent_of(X, ralf)");
while (q4.hasMoreSolutions()) {
solution = q4.nextSolution();
System.err.println("X = " + solution.get(X.name));
}
new Query("sleep", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
// --------------------------------------------------
Variable Y = new Variable("Y");
Query q5 = new Query("descendent_of", new Term[] { 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.name) + ", Y = " + solution.get(Y.name));
new Query("sleep", new Term[] { new org.jpl7.Integer(delay) }).hasSolution();
}
}
use of org.geotoolkit.sml.xml.v100.Term 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 = 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