/* Global constraint and in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Cand.html """ Let VARIABLES be a collection of 0-1 variables VAR1, VAR2, ..., VARn (n>=2). Enforce VAR=VAR1/\VAR2../\VARn. Example (0, <0, 0>) (0, <0, 1>) (0, <1, 0>) (1, <1, 1>) (0, <1, 0, 1>) """ 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 = 3, X = new_list(N), X :: 0..1, Y :: 0..1, X = [1,1,_], % Y #= 0, and(X,Y), Vars = X ++ [Y], solve(Vars), println(x=X), println(y=Y), nl, fail, nl. go => true. and(X, Y) => N = X.len, (Y #= 1) #<=> N #= sum([X[I] #= 1 : I in 1..N]).