Search in sources :

Example 31 with Term

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

the class TestOLD method test10m.

private static void test10m() {
    String text = "append(Xs,Ys,[_,_,_,_,_])";
    Query q = new Query(text);
    Map<String, Term>[] ss = q.allSolutions();
    System.err.println("test10m:");
    System.err.println("  all solutions of " + text);
    for (int i = 0; i < ss.length; i++) {
        System.err.println("  " + Util.toString(ss[i]));
    }
    System.err.println();
}
Also used : Query(org.jpl7.Query) Map(java.util.Map)

Example 32 with Term

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

the class TestOLD method test10q.

private static void test10q() {
    System.err.println("test10q:");
    System.err.println((new Compound("Bad Name", new Term[] { new Atom("3 3") })).toString());
    System.err.println();
}
Also used : Compound(org.jpl7.Compound) Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 33 with Term

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

the class TestJUnit method testStringXput2.

public void testStringXput2() {
    String s1 = "\u0000\u007F\u0080\u00FF";
    String s2 = "\u0100\u7FFF\u8000\uFFFF";
    // concatenate in Java
    String s = s1 + s2;
    // concatenate
    Term a = Query.oneSolution("string_concat(?,?,S)", new Term[] { new Atom(s1), new Atom(s2) }).get("S");
    // in
    // Prolog
    assertEquals(s, a.name());
    assertEquals("string", a.atomType());
}
Also used : Term(org.jpl7.Term) Atom(org.jpl7.Atom)

Example 34 with Term

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

the class TestJUnit method testEmptyParentheses.

// the tests; all public void test*()
// public void testInfo() {
// Term swi = Query.oneSolution("current_prolog_flag(version_data,Swi)").get("Swi");
// System.out.println("version = " + swi.arg(1) + "." + swi.arg(2) + "." + swi.arg(3));
// System.out.println("syntax = " + Query.oneSolution("jpl:jpl_pl_syntax(Syntax)").get("Syntax"));
// System.out.println("jpl.jar = " + JPL.version_string() + " " + JPL.jarPath());
// System.out.println("jpl.dll = " + Prolog.get_c_lib_version());
// System.out.println("jpl.pl = " + Query.oneSolution("jpl:jpl_pl_lib_version(V)").get("V").name() + " "
// + Query.oneSolution("module_property(jpl, file(F))").get("F").name());
// System.out.println("home = " + Query.oneSolution("current_prolog_flag(home,Home)").get("Home").name());
// }
public void testEmptyParentheses() {
    // valid in both
    Term t = Query.oneSolution("T = a()").get("T");
    // traditional and
    // modern syntax in SWI
    // Prolog 7.x
    assertTrue("T is not bound to an atom", t.isAtom());
    assertTrue("the atom's name is not \"a\"", t.name().equals("a"));
}
Also used : Term(org.jpl7.Term)

Example 35 with Term

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

the class TestJUnit method testStringXput1.

public void testStringXput1() {
    Term a = Query.oneSolution("string_concat(foo,bar,S)").get("S");
    assertEquals("foobar", a.name());
    assertEquals("string", a.atomType());
}
Also used : 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