Re: [eclipse-users] 'forall' predicate

From: Joachim Schimpf <js10_at_...2...>
Date: Thu, 29 Mar 2007 19:51:13 +0100
Malcolm Ryan wrote:
>...
> Basically, I want a way to do the equivalent of a lambda operation in  
> functional programming, on a constraint expression. So that I can  
> say: lambda(X, X #< N or X #> 0).

Using copy_term_vars/3 (mentioned by Ulrich), you can implement

apply(Lambda, Args) :-
	Lambda = lambda(Vars,_),
	copy_term_vars(Vars, Lambda, lambda(Args,Goal)),
	call(Goal).

and then use it to apply your constraints:

?- Con=lambda(X, X #< N or X #> 0), apply(Con,Y), apply(Con,Z), ...

This will of course also work with multiple arguments:

?- Con=lambda([X,Y], X #> Y), apply(Con,[Z,W]).


-- Joachim
Received on Thu Mar 29 2007 - 19:51:53 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST