Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Map;
  3. import org.jpl7.*;
  4. import org.jpl7.Integer;
  5.  
  6. public class InterfaceProlog {
  7.  
  8. public static void main(String argv[]) {
  9.  
  10. int[][] array = new int[3][3];
  11.  
  12. String t = "consult('ormat.pl')";
  13. org.jpl7.Query q = new org.jpl7.Query(t);
  14. System.out.println( t + " " + (q.hasSolution() ? "succeeded" : "failed") );
  15.  
  16. String t1 = "generuj([], 3, W)";
  17. org.jpl7.Query q1 = new org.jpl7.Query(t1);
  18. System.out.println("\n" + t1 + " has W = " + q1.oneSolution().get("W") );
  19.  
  20. String t2 = "k_comb(3, [3, 2, 1], L)";
  21. org.jpl7.Query q2 = new org.jpl7.Query(t2);
  22. //System.out.println( t2 + " has L = " + q1.oneSolution().get("L") );
  23.  
  24.  
  25. Map<String, Term>[] ss4 = q2.allSolutions();
  26. System.out.println( "\nall solutions of " + t2);
  27. for ( int i=0 ; i<ss4.length ; i++ ){
  28. System.out.println( "L = " + ss4[i].get("L"));
  29. String numberOnly = ss4[i].toString().replaceAll("[^0-9]","");
  30. System.out.println("liczby: " + numberOnly);
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement