View Single Post
  #2 (permalink)  
Old 02-20-2012, 11:50 PM
Feliks
Guest
 
Posts: n/a
Default Re: Variable Names in Prolog

On Feb 20, 11:46*am, Nada Sharaf <nada.shara...@gmail.com> wrote:
> Hello all. I have a problem that since variable names are always
> replaced with ones that start with _G I cannot know the mapping back.
> So, is there a way to know that variable _G123 maps to X for example,
> so that I can print X or write it to a file instead of having _G123
> written.
> Thank you very much


This is probably a little more complicated than what you want, but...

In SWI-Prolog (is that what you are using?) you can do
read_term( Term, [ variable_names( VarDict ) ] )
You can then call your own printing procedure that uses the names from
VarDict whenever it prints variables. I don't see a similar option in
write/2. :-(

The top level in SWI-Prolog will print your original variable names.
In general, many variables are created during the computation and just
don't have original names.

Hope this helps a little,
-- Feliks

Reply With Quote