Search in sources :

Example 21 with Compound

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

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

the class TestJUnit method testVariableBinding1.

public void testVariableBinding1() {
    Term lhs = new Compound("p", new Term[] { new Variable("X"), new Variable("Y") });
    Term rhs = new Compound("p", new Term[] { new Atom("a"), new Atom("b") });
    Term goal = new Compound("=", new Term[] { lhs, rhs });
    Map<String, Term> soln = new Query(goal).oneSolution();
    assertTrue("two Variables with different names can bind to distinct atoms", soln != null && (soln.get("X")).name().equals("a") && (soln.get("Y")).name().equals("b"));
}
Also used : Variable(org.jpl7.Variable) Query(org.jpl7.Query) Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

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