Search in sources :

Example 61 with Query

use of org.jpl7.Query in project packages-jpl by SWI-Prolog.

the class TestOLD method test10j.

private static void test10j() {
    Term l2 = Util.termArrayToList(new Term[] { new Atom("a"), new Atom("b"), new Atom("c"), new Atom("d"), new Atom("e") });
    Query q9 = new Query(new Compound("append", new Term[] { new Variable("Xs"), new Variable("Ys"), l2 }));
    Map<String, Term>[] s9s = q9.allSolutions();
    System.err.println("test10j:");
    for (int i = 0; i < s9s.length; i++) {
        System.err.println("  append(Xs,Ys,[a,b,c,d,e]) -> " + Util.toString(s9s[i]));
    }
    System.err.println();
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Map(java.util.Map) Atom(org.jpl7.Atom)

Example 62 with Query

use of org.jpl7.Query in project packages-jpl by SWI-Prolog.

the class TestOLD method main.

public static void main(String[] argv) {
    Prolog.set_default_init_args(new String[] { "libpl.dll", "-f", "none", "-g", "set_prolog_flag(debug_on_error,false)", "-q" });
    System.err.println("tag = " + Prolog.object_to_tag(new Query("hello")));
    test10k();
    test10();
    // test10h();
    // test10i();
    test10j();
    test10k();
    test10l();
    test10m();
    // test10n();
    test10o();
    // test10p();
    test10q();
    // test10r();
    // test10s();
    // test10t();
    // test10u();
    // test10v();
    String s = new String("" + '\0' + '\377');
    System.err.println("s.length = " + s.length());
    for (int i = 0; i < s.length(); i++) {
        System.err.print((new Integer(s.charAt(i))).toString() + " ");
    }
    System.err.println();
    System.err.println(new Query("atom_codes(A,[127,128,255,0])").oneSolution().toString());
}
Also used : Integer(org.jpl7.Integer) Query(org.jpl7.Query)

Example 63 with Query

use of org.jpl7.Query in project packages-jpl by SWI-Prolog.

the class Masstest method predQuery.

public void predQuery() {
    String st = "diagnose_declaration(1,[(sp, 'prefix', [('arg1', '+', 'list', 'Liste1'), ('arg2', '+', 'list', 'Liste2')])], DecMap, ErrorList)";
    Query stQuery = new Query(st);
    String errString = stQuery.oneSolution().get("ErrorList").toString();
    System.out.println("errString=" + errString);
}
Also used : Query(org.jpl7.Query)

Example 64 with Query

use of org.jpl7.Query in project packages-jpl by SWI-Prolog.

the class SyntaxError method main.

public static void main(String[] argv) {
    Query q = new Query("syntax)error");
    System.err.println(q.hasSolution() ? "yes" : "no");
}
Also used : Query(org.jpl7.Query)

Example 65 with Query

use of org.jpl7.Query in project packages-jpl by SWI-Prolog.

the class TestJUnit method testHasMoreElements1.

@SuppressWarnings("unchecked")
public void testHasMoreElements1() {
    StringBuffer sb = new StringBuffer();
    Query q = new Query("atom_chars(prolog, Cs), member(C, Cs)");
    Map<String, Term> soln;
    q.open();
    while (q.hasMoreElements()) {
        soln = (Map<String, Term>) q.nextElement();
        sb.append(((Atom) soln.get("C")).name());
    }
    q.close();
    assertEquals("Query#hasMoreElements() + Query#nextElement() work as intended", "prolog", sb.toString());
}
Also used : Query(org.jpl7.Query) Term(org.jpl7.Term)

Aggregations

Query (org.jpl7.Query)56 Term (org.jpl7.Term)33 Variable (org.jpl7.Variable)23 Atom (org.jpl7.Atom)16 Compound (org.jpl7.Compound)16 Map (java.util.Map)13 Query (com.google.datastore.v1.Query)12 Test (org.junit.Test)8 GqlQuery (com.google.datastore.v1.GqlQuery)7 Integer (org.jpl7.Integer)6 Datastore (com.google.datastore.v1.client.Datastore)4 SplitQueryFn (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.Read.SplitQueryFn)4 Entity (com.google.datastore.v1.Entity)3 RunQueryRequest (com.google.datastore.v1.RunQueryRequest)3 BigInteger (java.math.BigInteger)3 PrologException (org.jpl7.PrologException)3 PartitionId (com.google.datastore.v1.PartitionId)2 DeleteEntity (org.apache.beam.sdk.io.gcp.datastore.DatastoreV1.DeleteEntity)2 JPLException (org.jpl7.JPLException)2 Handle (org.skife.jdbi.v2.Handle)2