(java.lang.String argv[])
| 6 | |
| 7 | public class Zahed { |
| 8 | public static void main(java.lang.String argv[]) { |
| 9 | System.out.println("starting..."); |
| 10 | Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") }); |
| 11 | Query q1 = new Query(goal1); |
| 12 | if (!q1.hasSolution()) { |
| 13 | System.out.println("consult('zahed.pl') failed"); |
| 14 | return; |
| 15 | } |
| 16 | |
| 17 | // creates term t(v, [], a) |
| 18 | Term t2 = new Compound("t", new Term[] { new Atom("v"), JPL.LIST_NIL, new Atom("a") }); |
| 19 | |
| 20 | // list2 = [t(v, [], a)] |
| 21 | Compound list2 = new Compound(JPL.LIST_PAIR, new Term[] { t2, JPL.LIST_NIL }); |
| 22 | |
| 23 | // creates term t(c, q, []) |
| 24 | Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), JPL.LIST_NIL }); |
| 25 | |
| 26 | // list1 = [t(v, [], a), t(c, q , [])] |
| 27 | Compound list1 = new Compound(JPL.LIST_PAIR, new Term[] { t1, list2 }); |
| 28 | |
| 29 | Variable answer = new Variable("A"); |
| 30 | |
| 31 | // goal2 = gen([t(v, [], a), t(c, q , [])], A) |
| 32 | Compound goal2 = new Compound("gen", new Term[] { list1, answer}); |
| 33 | |
| 34 | System.out.println("The query constructed is: " + goal2.toString()); |
| 35 | Query q2 = new Query(goal2); |
| 36 | Map<String, Term> solution = q2.oneSolution(); |
| 37 | if (solution == null) { |
| 38 | System.out.println("failed"); |
| 39 | } else { |
| 40 | System.out.println(solution.get("A").toString()); |
| 41 | } |
| 42 | System.out.println("finished"); |
| 43 | } |
| 44 | } |
nothing calls this directly
no test coverage detected