MartyIX
MartyIX

Reputation: 28648

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.

Upvotes: 3

Views: 360

Answers (1)

Mats Carlsson
Mats Carlsson

Reputation: 1426

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

Upvotes: 8

Related Questions