binding variables to variables

View: New views
2 Messages — Rating Filter:   Alert me  

binding variables to variables

by schemelab :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If I assert the fact:

   assert(sleeps(X)).

and then query it:

[debug]  ?- sleeps(Z).

Yes


Why do I not see the memory location shared between the query and the fact, e.g:

Z = _f5ehaa23


Re: binding variables to variables

by Alan Baljeu :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Try this:

?- X = cat,    assert(sleeps(X)).

?- sleeps(Z).
Z = cat.

 
SWI doesn't bother to show Z=Z, and as for the predicate sleeps, it takes a parameter, and that works somewhat like regular languages: It doesn't represent a memory location, but something that gets instantiated when you call it.

Alan Baljeu




----- Original Message ----
From: metaperl.j <metaperl.j@...>
To: swi-prolog@...
Sent: Fri, October 23, 2009 2:59:06 PM
Subject: [SWIPL] binding variables to variables


If I assert the fact:

   assert(sleeps(X)).

and then query it:

[debug]  ?- sleeps(Z).

Yes


Why do I not see the memory location shared between the query and the fact,
e.g:

Z = _f5ehaa23


--
View this message in context: http://www.nabble.com/binding-variables-to-variables-tp26031617p26031617.html
Sent from the SWI Prolog mailing list archive at Nabble.com.

_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo..cgi/swi-prolog



      __________________________________________________________________
Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/

_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog