[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Constraining two vectors to be different
From: |
Thomas Bourdeaud'huy |
Subject: |
Constraining two vectors to be different |
Date: |
30 Jun 2003 19:13:54 +0200 |
Hi, I'm using the FD solver,
and try to define the predicate allDiferent(List_Of_Vectors)
I use this predicate not to verify that all the vectors are different,
but to constrain the variables of these vectors not to allow them to be
equals...
I know that \= and #\=# exist, but i defined :
vectDif(E1,E2):-
\=(E1,E2).
notIn(_,[]):-!.
notIn(E,[E1|List]):-
vectDif(E,E1),
notIn(E,List).
tousDif([_]):-!.
tousDif([E|List]):-
notIn(E,List),
tousDif(List).
And tested :
tousDif([[1,2],[3,4]]).
yes
tousDif([[1,2],[X,4]]).
yes
tousDif([[1,2],[X,2]]).
no
The last result is not the one i needed : i just wanted to make X <>
1...
If I use #\= or #\=# in the definition of vectDif, the results are :
tousDif([[1,2],[3,4]]).
uncaught exception: error(type_error(fd_evaluable,[1,2]),(#\=)/2)
tousDif([[1,2],[X,4]]).
uncaught exception: error(type_error(fd_evaluable,[1,2]),(#\=)/2)
What's wrong with my implementation ? Is there a 'dif' function in GNU
Prolog ?
Thanks,
Thomas Bourdeaud'huy
Ecole Centrale de Lille