Hi,<br>I am new to mercury and i am having a problem with determinism. I know main cannot be semidet, but how can i switch the code around so that the following example compiles? Any help would be greatly appreciated.<br><br>
:- module marray.<br><br>:- interface.<br><br>:- import_module io.<br><br>:- pred main(io::di, io::uo) is det.<br><br>:- implementation.<br><br>:- import_module list, string, array2d, int. <br><br>main(!IO) :-<br> new(5,5,["XXX"]) = MyArray,
<br> MyList = ["the","cat","chased","the","dog"],<br> add_input_string(MyList,MyArray, 0).<br><br><br>:- pred add_input_string(list(string)::in, array2d(list(string))::array2d_di, int::in) is semidet.
<br>add_input_string(TheList, Array, Number) :-<br> TheList = [Head|Tail], <br> ( Array ^ elem(0,Number) := [Head] ) = T3,<br> NextNumber is Number + 1,<br> add_input_string(Tail,T3,NextNumber).<br><br><br>C:\Documents and Settings\Nige\Desktop>mmc --make -E marray
<br>Making Mercury\cs\marray.c<br>marray.m:007: In `main(di, uo)':<br>marray.m:007: error: determinism declaration not satisfied.<br>marray.m:007: Declared `det', inferred `semidet'.<br>marray.m:016: call to `add_input_string(in, (
array2d.array2d_di), in)' can fai<br>l.<br>Error: system command received signal 1.<br>** Error making `Mercury\cs\marray.c'.<br><br><br>Thanks,<br><br>Nigel<br><br>