/* Global constraint arith in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Carith.html """ Enforce for all variables var of the VARIABLES collection to have var RELOP VALUE. Example (<4, 5, 7, 4, 5>, <, 9) The arith constraint holds since all values of the collection <4, 5, 7, 4, 5> are strictly less than 9. """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> X = [4,5,7,4,5], Y :: 0..9, arith(X,#<,Y), solve([Y]), println(Y), fail, nl. go => true. go2 => X = new_list(4), X :: 0..9, Y :: 0..5, arith(X,#<,Y), println(x1=X), println(y1=Y), solve(X ++ [Y]), println(y=Y), println(x=X), fail, nl. arith(X, Relop, Y) => foreach(Val in X) call(Relop,Val,Y) end.