[mercury-users] Higher-order predicates
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri May 31 00:23:40 AEST 2002
"Douglas Michael Auclair" <dauclair at hotmail.com> writes:
> I have some predicates, one of which is defined thus:
>
> :- pred foo(bar, bar).
> :- mode foo(in, in) is semidet.
> :- mode foo(in, out) is nondet.
> :- mode foo(out, in) is nondet.
>
> foo(X, Z) :- quux(X, Y), quux(Y, Z), X \= Z.
>
> The problem is that in my main, I cannot use foo as a higher-order predicate
> (for solutions); the compiler complains that this is not an implemented
> feature ("Taking the address of a pred with multiple modes") and suggests
> making a lambda expression. But:
>
> main -->
> { Foof = pred(X::in, Z::out) is nondet :- foo(X, Z),
> solutions(Foof(baz), Bars) },
> % using Bars
> .
>
> doesn't work either.
The problem here is a matter of syntax: you need parentheses around
lambda expressions. So that should be written as
main -->
{ Foof = (pred(X::in, Z::out) is nondet :- foo(X, Z)),
solutions(Foof(baz), Bars) },
% using Bars
.
--
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