Yes I agree, it will probably fail.
Unless you are able to better compose a question in terms of script logic, I very much doubt if you will be getting a competent specific answer.
The only items you put in quotes seemed to be the array element values "bla" and "blub" and not the array element names, not that they need to be in quotes as things stand.
Variable values are often dynamic (change), that would be one good reason to call them variables. This includes array variables. An array element name does not change, it simply exist or not. I think what you mean is the array sizes are dynamic. This does not really have the same significance in Tcl that it has elsewhere.
Let me give you one example of the confusion that you communicate :-
newarray(value,posarray1,posarray2,posarray3)
The name of the array is newarray, the name of the array element is some sort of string concatenation of the value in the other arrays plus the element names in the said other arrays (positions as you call it). However, what is the value of this element of newarray?
Code: Select all
set newarray(value,posarray1,posarray2,posarray3) ???
This would be my suggestion :-
The newarray element name is the value from the other arrays and the newarray element value is a list of the element names where it occurs in the other arrays
value array1 array2 array3
bla 1,3 2,8 1,9
blub 0,2 * 0,6
So, for example, the value blub occurs in array1(0,2) and array3(0,6) but does not occur at all in array2
With the correct code, this could yield
newarray(bla) {1,3 2,8 1,9}
newarray(blub) {0,2 "" 0,6}
Even this assumes certain things :-
1. The value blub is not duplicated in the original arrays (occurs in more than one element of any one of the arrays)
2. The values in the original arrays do not contain spaces (this is possible to deal with, but potentially more difficult)
I'm sorry to be negative about your question but it does indicate a lack of understanding of Tcl arrays. Probably you are coming to Tcl from an alternative language where arrays are what might be called more 'normal' in structure/behaviour. Hopefully the Tcl experts won't shoot me for saying that.