Re: [eclipse-clp-users] Getting legaly named variables / Unifiying Term Lists

From: Kish Shen <kisshen_at_cisco.com>
Date: Wed, 10 Feb 2010 22:50:35 +0000
Christian Wirth wrote:
> i'm currenlty using set_var_name in my programm to get lists like this:
> 
> List=[pred(Var#1,Var#2)].
> 

I am not quite sure what you mean by "get lists like this". 
lib(var_name) is designed purely to allow unique names for variables 
when they are printed. You should not use them in any other way.

> i have now a second list
> 
> List2=[pred(Var#3,Var#4),pred2(Var#3,Var#4)]
> 
> and then i call union(List,List2,Result) and Result becomes 
> [pred(Var#1,Var#2),pred2(Var#3,Var#4)], but i need 
> [pred(Var#1,Var#2),pred2(Var#1,Var#2)]
> 
I am not sure I understand how you got this. What exactly did you write?

I just tried:

set_var_name_counter('Var', 1),set_var_name([W,X,Y,Z], 'Var'),
L1 = [pred(W,X)], L2 = [pred(Y,Z),pred2(Y,Z)], union(L1,L2, L)

and here is the the result:

W = Var#1
X = Var#2
Y = Var#1
Z = Var#2
L1 = [pred(Var#1, Var#2)]
L2 = [pred(Var#1, Var#2), pred2(Var#1, Var#2)]
L = [pred(Var#1, Var#2), pred2(Var#1, Var#2)]

> this should work, but it only does with "normal" variable names like Var 
> .. not with the # in between.

I don't understand this at all. Using lib(var_name) should not have any 
effect on how the program behave, it only affects the way a variable's 
name is printed. What do you mean it does not work with # in between?

> Now i have to choices changing set_var_name to create legal names, but 
> the function is build in ??
> .. or to get union to somehow correctly consider all named variables ?

Are you somehow thinking of usng these names in your own source code? 
The source code names have nothing to do with the names lib(var_name) 
produces -- the non-legal names is there to prevent you confusing names 
you write in your source from the names printed using lib(var_name).

Cheers,

Kish
-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Wed Feb 10 2010 - 22:50:41 CET

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