Question

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?

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top