I'm familiarizing with the basic of MiniZinc. So, armed with the MiniZinc IDE, I write snippets like
solve satisfy;
string: s1 = "hello";
string: s2 = "world";
function list of int: cdr(list of int: v) =
[v[i] | i in 1..length(v)];
function list of string: cdr(list of string: v) =
[v[i] | i in 1..length(v)];
function string: concat(list of string: V) =
if length(V) == 0 then "" else V[0] ++ concat(cdr(V)) endif;
output [concat([s1," ",s2])++" "++show(cdr([1,2,3]))];
that displays
Compiling hello.mzn
Running hello.mzn
hello world [1, 2, 3]
----------
Finished in 49msec
now, the cdr of a list of ints seems to be wrong. I assume it's my bug, albeit I cannot spot it.
Could assertions help me here ? Since I'm going to use Gecode (and then I have Gist) to actually put my code in production, could I follow that route ?
Any hint appreciated...
edit this snippet
solve satisfy;
function list of string: cdr_s(list of string: v) =
[v[i] | i in 2..length(v)];
function string: vcat(list of string: V) =
if length(V) == 0 then "" else V[1] ++ vcat(cdr_s(V)) endif;
output [vcat(["hello"," ","world"])];
reports
MiniZinc: type error: no function or predicate with this signature found: `cdr_s(array[int] of string)'
/tmp/MiniZinc IDE-9nYiuF/hello.ozn:2