Re: [eclipse-clp-users] intersection

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Fri, 12 Dec 2014 14:03:04 +0000
On 12/12/14 07:43, Philippe de Rochambeau wrote:
> Hello,
>
> why does
>
> intersection([]..[1,2,3]. []..[1,2,3,4,5,6],X) not instanciate?
>
> Should you declare variables containing the two sets first?


I assume that you are talking about the ic_sets library.

Yes, for an unknown set you have to declare a variable.  There are alternative 
ways to do this.  Try the following in an interactive eclipse, e.g. tkeclipse:

?- lib(ic_sets).
Yes (0.12s cpu)

?- S1 in_set_range []..[1,2,3].
S1 = S1{([] .. [1, 2, 3]) : _321{0 .. 3}}
Yes (0.00s cpu)

?- S1 subsetof [1 2,3].
S1 = S1{([] .. [1, 2, 3]) : _338{0 .. 3}}
Yes (0.00s cpu)

?- intset(S1, 1, 3).
S1 = S1{([] .. [1, 2, 3]) : _302{0 .. 3}}
Yes (0.00s cpu)


You example can be written as

?- S1 subsetof [1, 2, 3], S2 subsetof [1, 2, 3, 4, 5, 6],
    ic_sets:intersection(S1, S2, X).
S1 = S1{([] .. [1, 2, 3]) : _721{0 .. 3}}
S2 = S2{([] .. [1, 2, 3, 4, 5, 6]) : _864{0 .. 6}}
X = X{([] .. [1, 2, 3]) : _998{0 .. 3}}
There are 6 delayed goals.
Yes (0.00s cpu)


-- Joachim
Received on Fri Dec 12 2014 - 14:03:15 CET

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:21 CEST