On Wed, 22 Mar 2006, michel levy wrote:

> ?- X*X #=23.
> no
> I don't understand how this answer is produced.
> I was expecting X #= 1..23
> ?- X*X #=25.
> X = 5
> yes
> I don't understand how this answer is produced.
> I was expecting X #= 1..25

Looks like X is taken as integer variable by gprolog. 23 is not a square,
so there is no (integer) solution. 25 is 5*5, so you get precisely 5 as
solution.

Note that we're talking of _finite_ domains. Real numbers are anything but
finite...

(If you want two-factor factorizations of some integer, try X*Y to get
other solutions besides the square root. Prolog can't bind the variable X
as two different values at the same time, i.e. X*X equals N only if X is
the square root of N.)


-- 
TOK


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

Reply via email to