Re: [eclipse-clp-users] Copying Eclipse Data / Re: OutOfProcessEclipse Error

From: Christian Wirth <>
Date: Thu, 24 Jun 2010 17:45:08 +0200
I'm trying to copy a nested term structure (a list and a tree).
When exporting the term structure, i replace all prolog-variables with 
strings by term_string
When importing, those strings get replaces back with a variable and all 
variables of the same string are getting unified ... but i have an error 
somewhere in the program that prevents the variable unification.
Meaning that when variable A gets replaced by a constant, other 
occurances of A are not getting replaced ?
I know the same variable name does not mean that it is the same 
variable, but that should be done by string_to_var, because if the 
string has already a replacement var, this var gets returned.

Sourcecode (for the list version):
loadConvert(List,Tree) :- varToConstRecList(List).
saveConvert(List,Tree) :- init,constToVarRecList(List).

init :- 

% if string is seen, return variable (should unify all occurances of the 
same string)
string_to_var(String,Var) :- logicStorage(String,Var),!.
string_to_var(String,Var) :- 

varToConstRecList([]) :- !.
varToConstRecList([[Index,Head:-Body]|Rest]) :- 

replace(F/A) :- !. %entry is only functor/arity
replace(Term) :- is_list(Term),(foreach(X,Term) do 
(var(X)->true;replace(X))),!. %entry is a list
replace(Term) :- functor(Term,F,A),(for(I,1,A),param(Term) 
%entry is a term

getReplace(Var,Replace) :- var(Var),term_string(Var,Replace),!. %arg is 
a var then replace
getReplace(Var,Replace) :- replace(Var),Replace=Var. %arg is no var then 
try list and term

constToVarRecList([]) :- !.
constToVarRecList([[Index,Head:-Body]|Rest]) :- 

replaceBack(Var) :- var(Var),!.
replaceBack(Term) :- is_list(Term),(foreach(X,Term) do 
replaceBack(Term) :- functor(Term,F,A),(for(I,1,A),param(Term) 

argreplace(Term,I) :- 
%argument is a string the replace
argreplace(Term,I) :- arg(I,Term,Arg),replaceBack(Arg).

Wit Jakuczun schrieb:
> W dniu 2010-06-24 16:28, Christian Wirth pisze:
>> As Info:
>> I fixed the problem by converting all variables to strings before
>> exporting (term_string)
> What do yo call variables? Are they Prolog variables?
> I would be grateful for some small example: what is this thing you are 
> trying to copy? :)
> Best regards
> PS
> By the way: - is not working...
Received on Thu Jun 24 2010 - 15:45:12 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET