clp problem w/ gnu prolog
- From: suranap@xxxxxxxxx
- Date: 14 Jul 2006 22:23:37 -0700
I wanted to collect a subset of variables from a list and establish an
'all_different' constraint. test1 works correctly, but I won't know the
size of the list in my real program. test2 does the same thing as test1
but the constraints don't work. Why is that?
% This runs correctly
test1(L) :-
fd_domain(L,1,4),
L = [A,B,C,D],
fd_all_different([A,B]),
fd_all_different([C,D]),
fd_labeling(L).
| ?- length(L,4),test1(L).
L = [1,2,1,2] ?
% This doesn't work the same.
test2(L) :-
fd_domain(L,1,4),
findall(V1,(for(C1,1,2),nth(C1,L,V1)),As),
findall(V2,(for(C2,3,4),nth(C2,L,V2)),Bs),
fd_all_different(As),
fd_all_different(Bs),
fd_labeling(L).
| ?- length(L,4),test2(L).
L = [1,1,1,1] ?
.
- Follow-Ups:
- Re: clp problem w/ gnu prolog
- From: Neng-Fa Zhou
- Re: clp problem w/ gnu prolog
- Prev by Date: Re: Any suggestion to build GUI with prolog
- Next by Date: Re: clp problem w/ gnu prolog
- Previous by thread: Any suggestion to build GUI with prolog
- Next by thread: Re: clp problem w/ gnu prolog
- Index(es):
Relevant Pages
|
|