[mercury-users] Det/Semidet
Nigel Evans
bignigeuk at gmail.com
Sat Dec 9 00:38:04 AEDT 2006
Hi,
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.
:- module marray.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list, string, array2d, int.
main(!IO) :-
new(5,5,["XXX"]) = MyArray,
MyList = ["the","cat","chased","the","dog"],
add_input_string(MyList,MyArray, 0).
:- pred add_input_string(list(string)::in,
array2d(list(string))::array2d_di, int::in) is semidet.
add_input_string(TheList, Array, Number) :-
TheList = [Head|Tail],
( Array ^ elem(0,Number) := [Head] ) = T3,
NextNumber is Number + 1,
add_input_string(Tail,T3,NextNumber).
C:\Documents and Settings\Nige\Desktop>mmc --make -E marray
Making Mercury\cs\marray.c
marray.m:007: In `main(di, uo)':
marray.m:007: error: determinism declaration not satisfied.
marray.m:007: Declared `det', inferred `semidet'.
marray.m:016: call to `add_input_string(in, (array2d.array2d_di), in)' can
fai
l.
Error: system command received signal 1.
** Error making `Mercury\cs\marray.c'.
Thanks,
Nigel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20061208/d345e2c8/attachment.html>
More information about the users
mailing list