/* Global constraint lex_different in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Clex_different.html """ lex_different(VECTOR1, VECTOR2) Purpose Vectors VECTOR1 and VECTOR2 differ in at least one component. Example ( <5, 2, 7, 1>, <5, 3, 7, 1> ) The lex_different constraint holds since VECTOR1 = <5, 2, 7, 1> and VECTOR2 = <5, 3, 7, 1> differ in their second component. """ 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 ?=> N = 4, Vector1 = new_list(N), Vector1 :: 1..7, Vector2 = new_list(N), Vector2 :: 1..7, % Vector1 = [5,2,7,1], % Vector2 = [5,3,7,1], Vector1 = [5,2,7,1], Vector2 = [5,_,7,1], lex_different(Vector1, Vector2), Vars = Vector1 ++ Vector2, solve(Vars), println(vector1=Vector1), println(vector2=Vector2), nl, fail, nl. go => true. lex_different(Vector1,Vector2) => sum([Vector1[I] #!= Vector2[I] : I in 1..Vector1.len]) #> 0.