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"));
}
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));
}
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());
}
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());
}
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");
}
Aggregations