Cancel
Showing results for 
Search instead for 
Did you mean: 

Array and List comparing

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hello

Could you please show me how to compare lists or arrays in tcl? (the simplest way)

For example: I have list (or array)  1234 and 2341 - and I want know that both are equal.

 

thank you very much

 

---------------------------------------------
#♫ PB, 5ax, itnc, nx, vericut ♫ #
5 REPLIES 5

Re: Array and List comparing

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

Other than searching on Google...

You can compare element-by-element

 

If order is NOT important, for the list case you can use "lsort" to sort both lists in some consistent order.

For the array case, if order is NOT important, it will be more difficult.

 

 

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled


Re: Array and List comparing

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I agree with Ken. If methods which you can google doesn't match your case, I would iterate arrays element-by-element doing comparison the way as I need.

I usually also encapsulate this comparison in separate procedure/method which simply returns result of the comparison.

Marek Pawlus, NCmatic

Development: C#, Tcl/Tk, CSE

Re: Array and List comparing

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

@Marek_Pawlus @Ken_A

thank you guys, understand and I will use something.

 

One more question,

Hope I will describe it well.

Problem:

I want to save list of some elements per operation - so I need more lists and then compare each other.

Is there some way to set new array with some increment or something?

 

---------------------------------------------
#♫ PB, 5ax, itnc, nx, vericut ♫ #

Re: Array and List comparing

Phenom
Phenom

@Juraj wrote:

 

I want to save list of some elements per operation - so I need more lists and then compare each other.

Is there some way to set new array with some increment or something?

 


Hi @Juraj ,

If I understand ,you can do with mom_operation_name (with nx you can't have 2 times the same name) :

set myarray($mom_operation_name) [list $mom_... $mom_...]
Production: NX11.0.2.7,VERICUT 8.1.2
Development: Tcl/Tk, Gnuplot
www.adgroupe.com

Re: Array and List comparing

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

@mkn this is quite interesting and simple

---------------------------------------------
#♫ PB, 5ax, itnc, nx, vericut ♫ #

Learn online





Solution Information