Kod Javy :
package scr.View;
import jpl.*;
public class LogTalkCaller {
public LogTalkCaller() {
JPL.setDefaultInitArgs(
new String[] {
"pl",
"-f", "none",
"-g", "set_prolog_flag(debug_on_error,false)",
"-q",
"-nosignals"
}
);
Query q = new Query("['lib/logtalkLoad.pl'].");
if (!q.hasSolution()) {
//RuntimeException e = new RuntimeException("error loading logtalk");
System.out.println("A miało być tak pięknie..");
}else {
System.out.println("Hurray!");
Query loadControler = new Query("logtalk_load",
new Term[]{
new Atom("src/Controler/logTalkControler")
}
);
System.out.println("Loaded?" + (loadControler.hasSolution()? "Tak":"A mialo byc tak pieknie..."));
askLogTalk.hasSolution();
}
}
public boolean askLogTalk(String query, String var) {
Query askLgt = new Query("logTalkControler::"+query + "(" + var +").");
return askLgt.hasSolution();
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
LogTalkCaller cal = new LogTalkCaller();
;
System.out.println("Is 'a' a proper TestValue?:"
+ (cal.askLogTalk("testValue", "a")?"YES":"NO!"));
System.out.println("Is 'b' a proper TestValue?:"
+ (cal.askLogTalk("testValue", "b")?"YES":"NO!"));
}
}
Kod obiektu LogTalk
:-object(logTalkControler).
:-public(toString/0).
:-public(testValue/1).
test(a).
test(b).
test(c).
value(a).
testValue(X) :-
test(X),
value(X).
:-end_object.