0

How do I revise this to compile in MiniZinc:

output [[show (P[j,p]) ++ "\n" | p in 1 .. 4] | j in 1 .. 4];

I tried several ways.

Jim Lewis
  • 349
  • 2
  • 14

1 Answers1

0

It depends on what you want to do. Here are some different approaches that will write P as a matrix. The first one write the matrix as lists ([...]), the second one just outputs the values.

output [  
   show([P[j,p] | p in 1 .. 4]) ++ "\n"
   | j in 1 .. 4
];


output [  
   if p = 1 then "\n" else " " endif ++
     show(P[j,p])
    | j in 1 .. 4, p in 1 .. 4
];

Update: In MiniZinc 2.0 (at least in a fairly recent Git version), there is now a show2d predicate:

 output [ show2d(P)];
hakank
  • 6,629
  • 1
  • 17
  • 27