Search in sources :

Example 31 with Term

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());
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 32 with Term

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");
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 33 with Term

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();
    }
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term) Map(java.util.Map)

Example 34 with Term

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") + "}");
    }
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Example 35 with Term

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");
    }
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Aggregations

Term (org.jpl7.Term)86 Query (org.jpl7.Query)52 Variable (org.jpl7.Variable)29 Atom (org.jpl7.Atom)23 Compound (org.jpl7.Compound)23 Map (java.util.Map)19 BigInteger (java.math.BigInteger)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 Integer (org.jpl7.Integer)4 Term (org.apache.cassandra.cql3.Term)3 MarshalException (org.apache.cassandra.serializers.MarshalException)3 JAXBElement (javax.xml.bind.JAXBElement)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 CodeType (org.geotoolkit.gml.xml.v311.CodeType)2 TimePositionType (org.geotoolkit.gml.xml.v311.TimePositionType)2 Capabilities (org.geotoolkit.sml.xml.v100.Capabilities)2 Classification (org.geotoolkit.sml.xml.v100.Classification)2 Classifier (org.geotoolkit.sml.xml.v100.Classifier)2