Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Map;
- import org.jpl7.*;
- import org.jpl7.Integer;
- public class InterfaceProlog {
- public static void main(String argv[]) {
- int[][] array = new int[3][3];
- String t = "consult('ormat.pl')";
- org.jpl7.Query q = new org.jpl7.Query(t);
- System.out.println( t + " " + (q.hasSolution() ? "succeeded" : "failed") );
- String t1 = "generuj([], 3, W)";
- org.jpl7.Query q1 = new org.jpl7.Query(t1);
- System.out.println("\n" + t1 + " has W = " + q1.oneSolution().get("W") );
- String t2 = "k_comb(3, [3, 2, 1], L)";
- org.jpl7.Query q2 = new org.jpl7.Query(t2);
- //System.out.println( t2 + " has L = " + q1.oneSolution().get("L") );
- Map<String, Term>[] ss4 = q2.allSolutions();
- System.out.println( "\nall solutions of " + t2);
- for ( int i=0 ; i<ss4.length ; i++ ){
- System.out.println( "L = " + ss4[i].get("L"));
- String numberOnly = ss4[i].toString().replaceAll("[^0-9]","");
- System.out.println("liczby: " + numberOnly);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement