Home > Archive > Prolog > August 2007 > X #= -Y fails in clp(FD)
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
X #= -Y fails in clp(FD)
|
|
| Andrey Rybalchenko 2007-08-15, 10:13 pm |
| Any ideas why? (Running Sicstus Prolog)
| ?- X in -1..1, Y in -1..1, X#= -Y.
! Domain error in user: #= /2
! expected constraint, found _1126#= -(_1124)
! goal: _1126#= -(_1124)
! goal: user:(_451#= -(_506))
! Domain error in user: #= /2
! expected constraint, found _140#= -(_105)
! goal: _140#= -(_105)
Bes regards,
Andrey
| |
| Andrey Rybalchenko 2007-08-15, 10:13 pm |
| after a quick look at the manual:
unary negation symbol is missing in clp(FD) language.
a workaround is to multiply by -1:
| ?- X in -1..1, Y in -1..1, X#= -1*(Y).
X in-1..1,
Y in-1..1 ?
yes
> Any ideas why? (Running Sicstus Prolog)
>
> | ?- X in -1..1, Y in -1..1, X#= -Y.
> ! Domain error in user: #= /2
> ! expected constraint, found _1126#= -(_1124)
> ! goal: _1126#= -(_1124)
> ! goal: user:(_451#= -(_506))
> ! Domain error in user: #= /2
> ! expected constraint, found _140#= -(_105)
> ! goal: _140#= -(_105)
>
>
> Bes regards,
>
> Andrey
| |
| Neng-Fa Zhou 2007-08-16, 7:10 pm |
| I think this is something that should be standardized for CLP(FD). In
B-Prolog, I got what are expected.
| ?- X in -1..1, Y in -1..1, X#= -Y,labeling([X,Y])
X = -1
Y = 1 ?;
X = 0
Y = 0 ?;
X = 1
Y = -1 ?;
no
| ?- X in -1..1, T = (X#=0), #\ T, labeling([], [X]).
X = -1
T = -1#=0 ?;
X = 1
T = 1#=0 ?;
no
Cheers,
Neng-Fa
"Andrey Rybalchenko" <first_dot_last_at_epfl_dot_ch> wrote in message
news:1187210291_654@sicinfo3.epfl.ch...[color=darkred]
> after a quick look at the manual:
>
> unary negation symbol is missing in clp(FD) language.
> a workaround is to multiply by -1:
>
> | ?- X in -1..1, Y in -1..1, X#= -1*(Y).
> X in-1..1,
> Y in-1..1 ?
> yes
>
|
|
|
|
|