Re: [eclipse-clp-users] Using sets ... generating two sets

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Sun, 04 Dec 2011 16:32:35 +0100
Claudio Cesar de Sá wrote:
> Hi
> 
> Please ... what is my mistake in this trivial example with sets:
> 
> %%:-lib(ic).
> %%:-lib(branch_and_bound).
> :-lib(fd).
> :-lib(fd_sets).
> 
> %% data
> veloc(1,[61,66,63,69]).
> veloc(4,[12,122,18,1,9,7]).
> 
> go :-
> veloc(1,L1), model(L1),
> veloc(4,L4), model(L4).
> 
> model(L) :-
> length(L,N), writeln( n: N), writeln( l: L),
> sort(L, Dominio),
> writeln( dom: Dominio),
> 
> find_2_others(N, N1, N2),
> 
> writeln( n1: N1) ,
> writeln( n2: N2) ,
> write('xxxxxxxx is it correct this definition?'),
>   L1 :: [ ] .. Dominio,
>   L2 :: [ ] .. Dominio,
>   L3 :: [ ] .. Dominio,
> 
> #(L1, N1),
> #(L2, N2),
> #(L3, N),
> 
> union(L1, L2, L3),
> 
> label_sets([L1, L2]).
> 
> The error is:
> 
> undefined arithmetic expression in _472 is [] in module fd_domain

You are calling the 'fd' version of the :: predicate (which is for declaring
integer-variables), but you want the 'fd_sets' version (for set-variables).
As Sergey already mentioned, when loading your code you got this warning:

Ambiguous import of :: / 2 from [fd, fd_sets] in module eclipse

telling you about this name conflict (which is due to an unfortunate
design decision by myself a couple of years ago...).

To tell ECLiPSe which version you want, you can write, for example:

    fd_sets:(L1 :: Dominio)

You need to do the same with the call to the union/3 constraint (which
conflicts with the union/3 predicate for standard lists), e.g.

    fd_sets:union(L1,L2,L3)

Alternative ways to resolve such name conflicts are described in
http://www.eclipseclp.org/doc/userman/umsroot040.html


-- Joachim
Received on Sun Dec 04 2011 - 15:33:21 CET

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