Search in sources :

Example 16 with Query

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

the class TestJUnit method testOpen2.

public void testOpen2() {
    Query q = new Query("fail");
    q.open();
    assertTrue("a newly opened query which has no solutions is open", q.isOpen());
}
Also used : Query(org.jpl7.Query)

Example 17 with Query

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

the class Versions method main.

public static void main(String[] argv) {
    System.out.println("command line args: (" + argv.length + ")");
    for (int i = 0; i < argv.length; i++) {
        System.out.println("  argv[" + i + "]: " + argv[i]);
    }
    System.out.println();
    System.out.println("old (built in) default init args:");
    String[] defaultInitArgsOld = org.jpl7.JPL.getDefaultInitArgs();
    for (int i = 0; i < defaultInitArgsOld.length; i++) {
        System.out.println("  arg[" + i + "]: " + defaultInitArgsOld[i]);
    }
    System.out.println();
    String[] defaultInitArgsNew1;
    if (argv.length == 1 && argv[0].equals("traditional")) {
        defaultInitArgsNew1 = new String[] { "swipl", "-g", "true", "--nosignals", "--traditional" };
    } else {
        defaultInitArgsNew1 = new String[] { "swipl", "-g", "true", "--nosignals" };
    }
    org.jpl7.JPL.setDefaultInitArgs(defaultInitArgsNew1);
    System.out.println("new (stashed) default init args:");
    String[] defaultInitArgsNew2 = org.jpl7.JPL.getDefaultInitArgs();
    for (int i = 0; i < defaultInitArgsNew2.length; i++) {
        System.out.println("  arg[" + i + "]: " + defaultInitArgsNew2[i]);
    }
    System.out.println();
    if (!(new Query("consult", new Atom("jpl/test/Versions.pl"))).hasSolution()) {
        System.out.println("Warning: failed to consult Versions.pl");
        System.out.println();
    }
    // String swiplHome = ((Term) (new
    // Query("current_prolog_flag(home,Home)")).oneSolution().get("Home")).name();
    // System.out.println(" SWI-Prolog home dir: " + swiplHome );
    System.out.println("home1 = " + (new Atom("c:/swipl-7.1.26")).toString());
    Query q1 = new Query("current_prolog_flag", new Term[] { new Atom("home"), new Variable("Home") });
    Map<String, Term> h1 = q1.oneSolution();
    Term home = (Term) h1.get("Home");
    // System.out.println("Home = " + home.debugString());
    System.out.println("Home = " + home.toString());
    try {
        URL jarPathJpl = Class.forName("org.jpl7.JPL").getProtectionDomain().getCodeSource().getLocation();
        System.out.println("package jpl loaded from: " + jarPathJpl);
    } catch (ClassNotFoundException e) {
        System.out.println("org.jpl7.JPL not found");
    }
    String prologVersion = ((Term) (new Query("jpl_pl_lib_version(V)")).oneSolution().get("V")).name();
    System.out.println(" prolog library version: " + prologVersion);
    String javaVersion = org.jpl7.JPL.version_string();
    System.out.println("   java library version: " + javaVersion);
    String cVersion = org.jpl7.fli.Prolog.get_c_lib_version();
    System.out.println("      c library version: " + cVersion);
    System.out.println("      SWI Prolog syntax: " + org.jpl7.fli.Prolog.get_syntax());
    // if ( prologVersion.equals(javaVersion) &&
    // javaVersion.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");
    // }
    System.out.println();
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Term(org.jpl7.Term) Atom(org.jpl7.Atom) URL(java.net.URL)

Example 18 with Query

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

the class TestOLD method test10l.

private static void test10l() {
    Query q5 = new Query(new Compound("length", new Term[] { new Variable("Zs"), new org.jpl7.Integer(5) }));
    Map<String, Term> s5 = q5.oneSolution();
    System.err.println("test10l:");
    System.err.println("  length(Zs,5)");
    System.err.println("  " + Util.toString(s5));
    System.err.println("  Zs = " + (Term) s5.get("Zs"));
    System.err.println();
}
Also used : Integer(org.jpl7.Integer) Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term)

Example 19 with Query

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

the class TestOLD method test10.

private static void test10() {
    System.err.println("test10:");
    System.err.println("  java_lib_version = " + JPL.version_string());
    System.err.println("  c_lib_version = " + org.jpl7.fli.Prolog.get_c_lib_version());
    System.err.println("  pl_lib_version = " + new Query(new Compound("jpl_pl_lib_version", new Term[] { new Variable("V") })).oneSolution().get("V"));
    System.err.println("  java.version = " + System.getProperty("java.version"));
    System.err.println("  os.name = " + System.getProperty("os.name"));
    System.err.println("  os.arch = " + System.getProperty("os.arch"));
    System.err.println("  os.version = " + System.getProperty("os.version"));
    System.err.println();
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term)

Example 20 with Query

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

the class TestOLD method test10o.

private static void test10o() {
    System.err.println("test10o:");
    Term l2b = Util.termArrayToList(new Term[] { new Variable("A"), new Variable("B"), new Variable("C"), new Variable("D"), new Variable("E") });
    Query q9b = new Query(new Compound("append", new Term[] { new Variable("Xs"), new Variable("Ys"), l2b }));
    Map<String, Term>[] s9bs = q9b.allSolutions();
    for (int i = 0; i < s9bs.length; i++) {
        System.err.println("  append(Xs,Ys,[A,B,C,D,E]) -> " + Util.toString(s9bs[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)

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