Search in sources :

Example 1 with Compound

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

the class Zahed method main.

public static void main(java.lang.String[] argv) {
    System.out.println("starting...");
    Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
    Query q1 = new Query(goal1);
    if (!q1.hasSolution()) {
        System.out.println("consult('zahed.pl') failed");
        return;
    }
    Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
    Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
    Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
    Compound list1 = new Compound(".", new Term[] { t1, list2 });
    Variable answer = new Variable("A");
    Compound goal2 = new Compound("gen", new Term[] { list1, answer });
    Query q2 = new Query(goal2);
    Map<String, Term> solution = q2.oneSolution();
    if (solution == null) {
        System.out.println("failed");
    } else {
        System.out.println(solution.get("A").toString());
    }
    System.out.println("finished");
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 2 with Compound

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

the class TestJUnit method testIsJNull1.

public void testIsJNull1() {
    Term atNull = new Compound("@", new Term[] { new Atom("null") });
    Query q = new Query("=", new Term[] { new Variable("X"), atNull });
    assertTrue(q.oneSolution().get("X").isJNull());
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 3 with Compound

use of org.jpl7.Compound 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 4 with Compound

use of org.jpl7.Compound 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 5 with Compound

use of org.jpl7.Compound 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

Compound (org.jpl7.Compound)21 Term (org.jpl7.Term)21 Variable (org.jpl7.Variable)17 Query (org.jpl7.Query)16 Atom (org.jpl7.Atom)13 Map (java.util.Map)4 Integer (org.jpl7.Integer)4 BigInteger (java.math.BigInteger)3 PrologException (org.jpl7.PrologException)2 JPLException (org.jpl7.JPLException)1 DoubleHolder (org.jpl7.fli.DoubleHolder)1 Int64Holder (org.jpl7.fli.Int64Holder)1 IntHolder (org.jpl7.fli.IntHolder)1 ObjectHolder (org.jpl7.fli.ObjectHolder)1 StringHolder (org.jpl7.fli.StringHolder)1 org.jpl7.fli.term_t (org.jpl7.fli.term_t)1