[mercury-users] Translating from Prolog
hanberg at ruc.dk
hanberg at ruc.dk
Thu Jun 10 04:57:31 AEST 2004
Hi again
I haven't really made it work - what I would like to have translated is:
closes(X & Y) :- closes(X), closes(Y).
closes(~~X) :- closes(X).
I've tried doing this(and a lot more):
:- type &(X, Y) ---> X & Y.
:- type ~(X) ---> ~X.
:- pred closes(_).
:- mode closes(in).
:- closes(X & Y) --> closes(X), closes(Y).
:- closes(~~X) --> closes(X).
But this doesn't seem to work - I must do someting simple wrong, but I have no
idea what.
Thank you very much for your help.
Tony
Quoting hanberg at ruc.dk:
> Quoting David Overton <dmo at cs.mu.OZ.AU>:
>
> > On Mon, Jun 07, 2004 at 04:51:02PM +0200, hanberg at ruc.dk wrote:
> > > I'm a Mercury newbie and would really like help to translate the
> following
> > from
> > > Prolog to Mercury:
> > >
> > > :- op( 500, xfy, &).
> > > :- op( 400, fy, ~).
> >
> > Mercury does not allow you to change the precedence of operators. Its
> > builtin definitions for & and ~ are
> >
> > :- op( 1025, xfy, &).
> > :- op( 900, fy, ~).
>
> Ok, I didn't know that they already were defined, since I tried using them
> and
> couldn't make it work.
>
> >
> > so you are stuck with those.
> >
> > > closes(~(X & Y)) :- closes(~X), closes(~Y).
> >
> > You can use this clause as is. You will need to define a type
> > containing your functions `~' and `&', and give type and mode
> > declarations for closes/1.
>
> I tried looking in the tutorial and on the Internet, but I can't really
> make
> that work. What would you write in a case like this?
>
> >
> >
> > David
> > --
> > David Overton
> > WWW: http://www.overtons.id.au/
> > Mobile Phone (UK): +44 7799 344 322
> >
> --------------------------------------------------------------------------
> > mercury-users mailing list
> > post: mercury-users at cs.mu.oz.au
> > administrative address: owner-mercury-users at cs.mu.oz.au
> > unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message:
> > unsubscribe
> > subscribe: Address: mercury-users-request at cs.mu.oz.au Message:
> subscribe
> >
> --------------------------------------------------------------------------
> >
> Thank you for your help!
>
> Tony
>
> --------------------------------------------------------------------------
> mercury-users mailing list
> post: mercury-users at cs.mu.oz.au
> administrative address: owner-mercury-users at cs.mu.oz.au
> unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message:
> unsubscribe
> subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
> --------------------------------------------------------------------------
>
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list