Różnice

Różnice między wybraną wersją a wersją aktualną.

Odnośnik do tego porównania

pl:miw:logtalktojavaexample [2019/06/27 15:50] (aktualna)
Linia 1: Linia 1:
 +Kod Javy :
 +<code java>
  
 +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!"​));​
 + }
 +
 +}
 +
 +</​code>​
 +
 +<code prolog>
 +
 +:​-object(logTalkControler).
 +:​-public(toString/​0).
 +:​-public(testValue/​1).
 +
 +test(a).
 +test(b).
 +test(c).
 +value(a).
 +
 +testValue(X) :-
 + test(X),
 + value(X).
 +
 +:​-end_object.
 +
 +
 +</​code>​
pl/miw/logtalktojavaexample.txt · ostatnio zmienione: 2019/06/27 15:50 (edycja zewnętrzna)
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0