JPL problem (newbie)
- From: "levilista@xxxxxxxxx" <levilista@xxxxxxxxx>
- Date: Thu, 22 May 2008 07:03:38 -0700 (PDT)
import jpl.*;
public class Test01 {
public static void main(String[] args) {
JPL.init();
Query q1 =
new Query(
"consult",
new Term[] {new Atom("test.pl")}
);
System.out.println( "consult " + (q1.query() ? "succeeded" :
"failed"));
Variable X = new Variable();
Query q4 =
new Query(
"descendent_of",
new Term[] {X,new Atom("ralf")}
);
java.util.Hashtable solution;
solution = q4.oneSolution();
System.out.println( "first solution of descendent_of(X, ralf)");
System.out.println( "X = " + solution.get(X));
}
}
With the example from "Getting started":
child_of(joe, ralf).
child_of(mary, joe).
child_of(steve, joe).
descendent_of(X, Y) :-
child_of(X, Y).
descendent_of(X, Y) :-
child_of(Z, Y),
descendent_of(X, Z).
The output:
consult succeeded
first solution of descendent_of(X, ralf)
X = null
% test.pl compiled 0.00 sec, 2,500 bytes
.
- Follow-Ups:
- Re: JPL problem (newbie)
- From: levilista@xxxxxxxxx
- Re: JPL problem (newbie)
- Prev by Date: Re: Networking in Prolog - a survey
- Next by Date: Re: JPL problem (newbie)
- Previous by thread: Visual Prolog Application and Language Conference 2008 in Saint Petersburg
- Next by thread: Re: JPL problem (newbie)
- Index(es):
Relevant Pages
|