Search in sources :

Example 36 with Term

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

the class TestJUnit method testTermToTermArray1.

public void testTermToTermArray1() {
    String goal = "T = [a,b,c]";
    Term list = Query.oneSolution(goal).get("T");
    Term[] array = list.toTermArray();
    assertTrue(array[2].isAtom() && array[2].name().equals("c"));
}
Also used : Term(org.jpl7.Term)

Example 37 with Term

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

the class TestJUnit method testJRef5.

public void testJRef5() {
    String token = "foobar345";
    Term a = Query.oneSolution("jpl_new('java.lang.StringBuffer',[?],A)", new Term[] { new Atom(token) }).get("A");
    assertTrue(((java.lang.StringBuffer) (a.jrefToObject())).toString().equals(token));
}
Also used : Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 38 with Term

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

the class TestJUnit method testIsJNull4.

public void testIsJNull4() {
    Term t = Query.oneSolution("X = @(true)").get("X");
    assertFalse("@(true) . isJNull() fails", t.isJNull());
}
Also used : Term(org.jpl7.Term)

Example 39 with Term

use of org.jpl7.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 40 with Term

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

Aggregations

Term (org.jpl7.Term)62 Query (org.jpl7.Query)42 Variable (org.jpl7.Variable)24 Atom (org.jpl7.Atom)21 Compound (org.jpl7.Compound)21 Map (java.util.Map)12 BigInteger (java.math.BigInteger)6 Integer (org.jpl7.Integer)6 org.jpl7.fli.term_t (org.jpl7.fli.term_t)4 Term (org.apache.cassandra.cql3.Term)3 MarshalException (org.apache.cassandra.serializers.MarshalException)3 PrologException (org.jpl7.PrologException)3 JPLException (org.jpl7.JPLException)2 IntHolder (org.jpl7.fli.IntHolder)2 URL (java.net.URL)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TestSuite (junit.framework.TestSuite)1 DoubleHolder (org.jpl7.fli.DoubleHolder)1 Int64Holder (org.jpl7.fli.Int64Holder)1 ObjectHolder (org.jpl7.fli.ObjectHolder)1