00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 import java.util.Hashtable;
00031 import jpl.*;
00032
00033 public class Zahed
00034 {
00035 public static void
00036 main( java.lang.String argv[] )
00037 {
00038
00039 System.out.println( "starting..." );
00040
00041 Compound goal1 = new Compound("consult", new Term[] { new Atom("zahed.pl") });
00042 Query q1 = new Query(goal1);
00043 if ( !q1.hasSolution() ){
00044 System.out.println( "consult('zahed.pl') failed" );
00045 return;
00046 }
00047
00048 Term t2 = new Compound("t", new Term[] { new Atom("v"), new Atom("[]"), new Atom("a") });
00049 Compound list2 = new Compound(".", new Term[] { t2, new Atom("[]") });
00050
00051 Compound t1 = new Compound("t", new Term[] { new Atom("c"), new Atom("q"), new Atom("[]") });
00052 Compound list1 = new Compound(".", new Term[] { t1, list2 });
00053
00054 Variable answer = new Variable("A");
00055
00056 Compound goal2 = new Compound("gen", new Term[] { list1, answer });
00057
00058 Query q2 = new Query(goal2);
00059 Hashtable solution = q2.oneSolution();
00060 if ( solution == null ) {
00061 System.out.println( "failed" );
00062 } else {
00063 System.out.println( solution.get("A").toString());
00064 }
00065 System.out.println( "finished" );
00066 }
00067 }