<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>
Can anyone help me to explain the compilation errors?<br>I am trying to combine elements two lists of type1 to get a list of type2.<br><br>Thanks in advance...<br>-<br><br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>stormie@stormie-laptop:~/logic/dvl_mercury/testmod$ mmc --make exp1<br>Making Mercury/int3s/exp1.int3<br>Making Mercury/ints/exp1.int<br>Making Mercury/cs/exp1.c<br>exp1.m:040: In `combine'(in, in, out):<br>exp1.m:040: error: determinism declaration not satisfied.<br>exp1.m:040: Declared `det', inferred `semidet'.<br>exp1.m:041: In argument 2 of clause head:<br>exp1.m:041: unification of `HeadVar__2' and `list.[]' can fail.<br>exp1.m:042: In argument 2 of clause head:<br>exp1.m:042: unification of `HeadVar__2' and `list.[B | Bs]' can fail.<br><br><br>%%%%%%%%%% Start of Mercury Code<br>:- module exp1.<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.<br><br>:- type type1 ---> t(string).<br><br>:- type type2 ---> c(type1,type1).<br><br>main(!IO) :-<br> io.write_string('Halo!! !! \n', !IO),<br> X = [t('1'),t('2'),t('3'),t('4')],<br> Y = [t('a'),t('b'),t('c'),t('d')],<br> combine(X,Y,Out),<br> displayt2(Out,!IO).<br><br><br>:- pred displayt1(list(type1)::in,io::di, io::uo) is det.<br>displayt1([],!IO).<br>displayt1([X|Xs],!IO):-<br> displayt1(Xs,!IO),<br> io.write(X,!IO).<br><br><br>:- pred displayt2(list(type2)::in,io::di, io::uo) is det.<br>displayt2([],!IO).<br>displayt2([X|Xs],!IO):-<br> displayt2(Xs,!IO),<br> io.write(X,!IO).<br><br><br>:- pred combine( list(type1)::in, list(type1)::in, list(type2)::out) is det.<br>combine( [], [] ,G) :- G = [].<br>combine( [A|As],[B|Bs], G):-<br> combine(As, Bs, G1),<br> append([c(A,B)],G1,G).<br><br><br>%%%%%%%%%%%%%%%%%%%%%%% End of Mercury Code<br><br><br>--<br>I am able to work out similar logic in prolog, <br>e.g. with following using constraints<br>combine( [], [] ,G) :- G = [].<br>combine( [A|As],[B|Bs], G):-<br> combine(As,Bs, G1),<br> append([c(A,B)],G1,G)<br><br>applying goal of <br>?- combine([x,y,z],[1,2,3],G).<br>G = [c(x, 1), c(y, 2), c(z, 3)] ;<br><br>No<br><br /><hr />Find what you want @ www.eBay.com.au. <a href='http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Frover%2Eebay%2Ecom%2Frover%2F1%2F705%2D10129%2D5668%2D323%2F4%2F%3Fid%3D6&_t=763807330&_r=email_taglines_EBAY&_m=EXT' target='_new'>Make shopping exciting. </a></body>
</html>