00001
00002
00003 import jpl.*;
00004
00005 public class Test2
00006 { public static int fac(int n)
00007 { if (n == 1)
00008 { return 1;
00009 } else
00010 { return n * ((jpl.Integer)
00011 new Query(new Compound("jpl_test_fac", new Term[]
00012 { new jpl.Integer(n - 1),
00013 new Variable("F")
00014 })).oneSolution().get("F")).intValue();
00015 }
00016 }
00017
00018 public static void
00019 main( java.lang.String argv[] )
00020 { new Query("consult('test2.pl')").oneSolution();
00021
00022 System.out.print( "calling Prolog to call Java to call Prolog...\n" );
00023
00024 System.out.println( "factorial(10) = " + fac(10));
00025 }
00026 }