Search code examples
prologconstraint-programmingclpfdsicstus-prolog

How to define a variable domain to be non-continuous range


I'm starting with SICStus Prolog and I would like to define a variable, say StartingTimes, to have a domain defined by list [1, 5, 10]

How can I do it in SICStus Prolog?

I would do something like:

 domain(StartingTimes, 1, 10)
 StartingTimes #= 1 #\/ StartingTimes #= 5 #\/ StartingTimes #= 10

But that is horrible. There must be a simple way how to do that. Maybe fd_sets?

Note: I tried to find out how it is done in manual but the prolog uses common words and it's really hard to use google for that.


Solution

  • ?- use_module(library(clpfd)). 
    ?- StartingTimes in {1,5,10}.