# Working with Range expressions in clpfd

**URL:** <https://swi-prolog.discourse.group/t/working-with-range-expressions-in-clpfd/6305>\
**Category:** Data Structure\
**Created:** [February 25, 2023, 3:23pm UTC](https://swi-prolog.discourse.group/t/working-with-range-expressions-in-clpfd/6305 "2023-02-25T15:23:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Losbarthos](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/losbarthos/32/4037_2.png) [@Losbarthos](https://swi-prolog.discourse.group/u/Losbarthos)\
**Post date:** [February 25, 2023, 3:23pm UTC](https://swi-prolog.discourse.group/t/working-with-range-expressions-in-clpfd/6305/1 "2023-02-25T15:23:27Z")

</div>

Why it is not possible to call based on library  
`:- use_module(library(clpfd)).`  
something like this:  
`A=(1\/(2\/3))/\ (\3), range_to_fdset(A,FDA).`

My aim also ist to build in clpfd something like the difference of two sets, means `A \ B`. The only way I get through it was based on this documentary

[https://www.complang.tuwien.ac.at/sicstus/sicstus\_32.html](https://www.complang.tuwien.ac.at/sicstus/sicstus_32.html)

`(A /\ (\B))`

---

<div class="post-metadata">

**Author:** ![Ian](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/ian/32/1026_2.png) [@Ian](https://swi-prolog.discourse.group/u/Ian)\
**Post date:** [February 27, 2023, 9:34am UTC](https://swi-prolog.discourse.group/t/working-with-range-expressions-in-clpfd/6305/2 "2023-02-27T09:34:35Z")

</div>

Sicstus CLPFD library is different from SWI’s CLPFD library which in turn is different from GNU-Prolog’s CLPFD library. This is why syntax from one version may not work in another.

In your case, SWI’s clpfd doesn’t define /\ or \ as operators. You will have to look at the corresponding libraries to try and figure out an alternative.  
e.g.

```prolog
?- X in 1\/3,fd_set(X,XSet),fdset_complement(XSet,XCompliment),fdset_to_range(XCompliment,CompRange),Y in CompRange.
XSet = split(2, from_to(n(1), n(1)), from_to(n(3), n(3))),
XCompliment = split(1, from_to(inf, n(0)), split(3, from_to(n(2), n(2)), from_to(n(4), sup))),
CompRange = inf..0\/2\/4..sup,
X in 1\/3,
Y in inf..0\/2\/4..sup.

```

Note there exists fdset\_subtract/3 which may help with your set difference implementation.
