문제

I can specify variable's domain in this way:

MyVar in 1..10

or

MyVar in {1,10,15}

but I have a variable which I would like to specify like this:

Activity_1__room in {room_1, room_2}  % i.e. as atoms not as integers

Is it possible to do it? Of course, it is possible to encode the names to integers but is it really necessary?

도움이 되었습니까?

해결책

You can't use atoms. The domains in CLPFD range over integers.

But suppose that you want to say "MyVar should take one of the values of the list L", i.e. the set is not known a priori. This can be coded as:

?- list_to_fdset(L, Set),
   MyVar in_set Set.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top