[mercury-users] Higher-order predicates

Fergus Henderson fjh at cs.mu.OZ.AU
Fri May 31 18:16:49 AEST 2002


On 30-May-2002, Douglas Michael Auclair <dauclair at hotmail.com> wrote:
> >From: Fergus Henderson <fjh at cs.mu.OZ.AU>
> >>from me
> > > main -->
> > >   { Foof = pred(X::in, Z::out) is nondet :- foo(X, Z),
> > > doesn't work either.
> 
> *blush* I just reviewed my sources, and there are the parentheses around the 
> higher-order predicate definition as you write (I copied the sources 
> incorrectly onto the email, sorry).  However, the error does not go away.  
...
> main -->
>   { Foo = (pred(X::in, Z::out) is nondet :- foo(X, Z)),
>     solutions(Foo(red), Colors) }, % compiler error thrown here

Oh, right, there is another error as well.
The problem is that partial application, e.g. passing `foo(red)'
when `foo' is a predicate that takes two arguments,
only works for predicates (e.g. `foo'), not for variables (e.g. `Foo').

So you need to write it as

	main -->
	  { FooRed = (pred(Z::out) is nondet :- foo(red, Z)),
	    solutions(FooRed, Colors) },
	  ...

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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