I am trying to use constrain X to not being a value in a list.
From the SICStus Prolog manual:
?X in_set +FDSet
I can’t figure out how to convert a list to a FDSet, though.
I have a list of integers [2,3,8,9] and I want to constrain the domain of variable X to not being in that list. How do I do that? Thanks.
Judging from the documentation, what about
list_to_fdset/2? You can translate to anFDSet, then build its complement, then postin_set/2. If your version does not havelist_to_fdset/2, you can easily convert the list to a normal domain expression, and then post a negatedin/2constraint. In your example, you would then post:and you only have to describe the relation between a list and a domain expression consisting of singletons, which is easy:
Example queries: