use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class TestJUnit method testOpenGetClose1.
public void testOpenGetClose1() {
StringBuffer sb = new StringBuffer();
Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
Map<String, Term> soln;
q.open();
while ((soln = q.getSolution()) != null) {
sb.append(((Atom) soln.get("C")).name());
}
q.close();
assertEquals("prolog", sb.toString());
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class FetchBigTree 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" });
(new Query("consult('jpl/test/test.pl')")).oneSolution();
Term t = (Term) ((new Query("p(18,T)")).oneSolution().get("T"));
int i = 1;
while (t.hasFunctor("a", 2)) {
t = t.arg(2);
i = i + 1;
}
System.err.println("got a tree of " + i + " generations");
}
use of org.geotoolkit.sml.xml.v100.Term 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.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class SemWeb method main.
public static void main(String[] argv) {
String t1 = "use_module(library('semweb/rdf_db'))";
System.out.println(t1 + " " + (Query.hasSolution(t1) ? "succeeded" : "failed"));
//
String t2 = "rdf_load('test.rdf')";
System.out.println(Query.hasSolution(t2) ? "loaded" : "load failed");
//
String t3 = "rdf(S,P,O)";
Query q3 = new Query(t3);
while (q3.hasMoreSolutions()) {
Map<String, Term> s3 = q3.nextSolution();
System.out.println("{" + s3.get("S") + ", " + s3.get("P") + ", " + s3.get("O") + "}");
}
}
use of org.geotoolkit.sml.xml.v100.Term in project packages-jpl by SWI-Prolog.
the class Init 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");
}
}
Aggregations