Alexandre Saidi wrote:
Hello all,
I know that Gprolog does not handle negative intergers.

However, someone could tell me why gprolog rejects vilently this :

?- fd_domain(I,1,4), fd_element(I,[12, 5, -7,9], X).

Fatal Error: Segmentation Violation

Ok, she does not like my -7.

But with :
X #= -1.
I get just (gently)
no.

PS : the original resuest was :
?- fd_domain([S1, S2], 1, 7), S1 #=S2 +X, fd_domain(I,1,4), fd_element(I,[-1,-2,1,2], X), fd_labeling([S1,S2]).

I'm trying to get S1 and S2 (2 days of a week) being two consecutive days or with a difference of 2 . An elegant way to this in gprolog (a short one is wellcome : I'm trying to illustratre CLP power in an introduction).

Thanks.
Alex

_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog
Les variables à domaine finis sont des entiers positifs ou nuls.
Donc en posant cette requête, vous contraignez X à être positif et négatif.

The FD variables are positive or nul integers.
Your request fd_element(I,[12, 5, -7,9], X) constrains X to be positive and negative : I am not surprised by this segmentation violation, but in the gprolog manual (8.8.2) this case is not referenced.


Another example :
[EMAIL PROTECTED] ~]$ gprolog
GNU Prolog 1.2.19
By Daniel Diaz
Copyright (C) 1999-2005 Daniel Diaz
| ?- fd_element(1,[-1],X).
Fatal Error: Segmentation Violation

But
| ?- fd_element_var(1,[-1],X).
no

And now let's return to your example
| ?- fd_element_var(I,[12, 5, -7,9], X).
I = _#3(1..2:4)
X = _#71(5:9:12)
yes
| ?- fd_element(I,[12, 5, -7,9], X).
Fatal Error: Segmentation Violation




--
Michel Levy
36 rue George Sand
38400 Saint Martin d'Heres



_______________________________________________
Users-prolog mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/users-prolog

Reply via email to