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 = (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");
}
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 Versions method report_versions.
public static void report_versions() {
System.out.println("REPORTING VERSION INFO: \n");
System.out.println("\t swipl.home = " + Query.oneSolution("current_prolog_flag(home, Home)").get("Home").name());
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));
String pVersion = new Query("jpl_pl_lib_version(V)").oneSolution().get("V").name();
String jVersion = JPL.version_string();
String cVersion = Prolog.get_c_lib_version();
System.out.println("prolog library version (jpl.pl): " + pVersion);
System.out.println(" java library version (jpl.jar): " + jVersion);
System.out.println(" c library version (libjpl.so): " + cVersion);
if (pVersion.equals(jVersion) && jVersion.equals(cVersion)) {
System.out.println("BINGO! you appear to have the same version of each library installed");
} else {
System.out.println("WHOOPS! you appear not to have the same version of each library installed");
}
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Family method main.
public static void main(String[] argv) {
// JPL.setTraditional();
//
// only because we call e.g. jpl_pl_syntax/1 below
Query.hasSolution("use_module(library(jpl))");
Term swi = Query.oneSolution("current_prolog_flag(version_data,Swi)").get("Swi");
System.out.println("swipl.version = " + swi.arg(1) + "" + swi.arg(2) + "." + swi.arg(3));
System.out.println("swipl.syntax = " + Query.oneSolution("jpl_pl_syntax(Syntax)").get("Syntax"));
System.out.println("swipl.home = " + Query.oneSolution("current_prolog_flag(home,Home)").get("Home").name());
System.out.println("jpl.jar = " + JPL.version_string());
System.out.println("jpl.dll = " + org.jpl7.fli.Prolog.get_c_lib_version());
System.out.println("jpl.pl = " + Query.oneSolution("jpl_pl_lib_version(V)").get("V").name());
//
String t1 = "consult('family.pl')";
System.out.println(t1 + " " + (Query.hasSolution(t1) ? "succeeded" : "failed"));
//
String t2 = "child_of(joe, ralf)";
System.out.println(t2 + " is " + (Query.hasSolution(t2) ? "provable" : "not provable"));
//
String t3 = "descendent_of(steve, ralf)";
System.out.println(t3 + " is " + (Query.hasSolution(t3) ? "provable" : "not provable"));
//
String t4 = "descendent_of(X, ralf)";
System.out.println("first solution of " + t4 + ": X = " + Query.oneSolution(t4).get("X"));
Map<String, Term>[] ss4 = Query.allSolutions(t4);
System.out.println("all solutions of " + t4);
for (int i = 0; i < ss4.length; i++) {
System.out.println("X = " + ss4[i].get("X"));
}
System.out.println("each solution of " + t4);
Query q4 = new Query(t4);
while (q4.hasMoreSolutions()) {
Map<String, Term> s4 = q4.nextSolution();
System.out.println("X = " + s4.get("X"));
}
//
String t5 = "descendent_of(X,Y)";
Query q5 = new Query(t5);
System.out.println("each solution of " + t5);
while (q5.hasMoreSolutions()) {
Map<String, Term> s5 = q5.nextSolution();
System.out.println("X = " + s5.get("X") + ", Y = " + s5.get("Y"));
}
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Init method report_all_flags.
public static void report_all_flags() {
System.out.println("REPORTING ALL FLAGS: \n");
Query q = new Query("current_prolog_flag(X, Y)");
while (q.hasMoreSolutions()) {
Map<String, Term> sol = q.nextSolution();
System.out.println(String.format("\t Value of %s: %s", sol.get("X").toString(), sol.get(("Y"))));
}
}
Aggregations