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]). -- JoachimReceived on Thu Mar 29 2007 - 19:51:53 CEST
This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST