Hi,
I am quite new to TCL and get confused a lot with lists and arrays. I have a problem wherein I need to search for a particular pattern in a list, extract the values from the list (The list has three elements) and build an array. The patterns to search are stored in an array.
E.g
List L= {A RED 1} {B BLACK 2} {C GREEN 3} {D PINK 4}
Array =A.index=10,C.index=4,A.RED=Anything,C.GREEN=Something
The aim is to build an array with values and index positions obtained from the search i.e.,If there is a match between the array names and the first and second element of the list (i.e., A.RED, B.BLACK, C.GREEN):
i. Index extracted from the third element of the list (1, 2, 3, 4)
ii. Value extracted from index values of the array (A.index, B.index).
To make it more clear in the above example there is a match for A.RED and C.GREEN therefore the final array would look like:
final(1)=10 (Index=1 because A.RED is 1 in the list)
final(3)=4 (Index=1 because C.GREEN is 3 in the list)
I have tried a variety of lsearch, lindexes but some teething problems still appear. Can someone help me with this ?
I am quite new to TCL and get confused a lot with lists and arrays. I have a problem wherein I need to search for a particular pattern in a list, extract the values from the list (The list has three elements) and build an array. The patterns to search are stored in an array.
E.g
List L= {A RED 1} {B BLACK 2} {C GREEN 3} {D PINK 4}
Array =A.index=10,C.index=4,A.RED=Anything,C.GREEN=Something
The aim is to build an array with values and index positions obtained from the search i.e.,If there is a match between the array names and the first and second element of the list (i.e., A.RED, B.BLACK, C.GREEN):
i. Index extracted from the third element of the list (1, 2, 3, 4)
ii. Value extracted from index values of the array (A.index, B.index).
To make it more clear in the above example there is a match for A.RED and C.GREEN therefore the final array would look like:
final(1)=10 (Index=1 because A.RED is 1 in the list)
final(3)=4 (Index=1 because C.GREEN is 3 in the list)
I have tried a variety of lsearch, lindexes but some teething problems still appear. Can someone help me with this ?