Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

TCL proc to generate : variable nb of lists which contain a variable nb of elem

Status
Not open for further replies.

pierre13

Junior Member level 3
Junior Member level 3
Joined
Aug 9, 2012
Messages
27
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,725
Hello,
I would like to implement in Tcl a procedure which generates the following element lists (example with 4 lists) :


list1_1 list2_1 list3_1 list4_1
list1_1 list2_1 list3_1 list4_2
list1_1 list2_1 list3_1 list4_3
list1_1 list2_1 list3_2 list4_1
list1_1 list2_1 list3_2 list4_2
list1_1 list2_1 list3_2 list4_3
list1_1 list2_2 list3_1 list4_1
list1_1 list2_2 list3_1 list4_2
list1_1 list2_2 list3_1 list4_3
list1_1 list2_2 list3_2 list4_1
list1_1 list2_2 list3_2 list4_2
list1_1 list2_2 list3_2 list4_3
list1_1 list2_3 list3_1 list4_1
list1_1 list2_3 list3_1 list4_2
list1_1 list2_3 list3_1 list4_3
list1_1 list2_3 list3_2 list4_1
list1_1 list2_3 list3_2 list4_2
list1_1 list2_3 list3_2 list4_3
list1_1 list2_4 list3_1 list4_1
list1_1 list2_4 list3_1 list4_2
list1_1 list2_4 list3_1 list4_3
list1_1 list2_4 list3_2 list4_1
list1_1 list2_4 list3_2 list4_2
list1_1 list2_4 list3_2 list4_3
list1_2 list2_1 list3_1 list4_1
list1_2 list2_1 list3_1 list4_2
list1_2 list2_1 list3_1 list4_3
list1_2 list2_1 list3_2 list4_1
list1_2 list2_1 list3_2 list4_2
list1_2 list2_1 list3_2 list4_3
list1_2 list2_2 list3_1 list4_1
list1_2 list2_2 list3_1 list4_2
...
list1_3 list2_4 list3_1 list4_2
list1_3 list2_4 list3_1 list4_3
list1_3 list2_4 list3_2 list4_1
list1_3 list2_4 list3_2 list4_2
list1_3 list2_4 list3_2 list4_3



However, the difficulty comes from the fact that the number of lists is variable, and the number of the elements of each list is also variable.




Example :


set list_1 "list1_1 list1_2 list1_3"
set list_2 "list2_1 list2_2 list2_3 list2_4"
set list_3 "list3_1 list3_2"
set list_4 "list4_1 list4_2 list4_3"


list1_1 is the first element of the list_1 and so on.






I have already made the following procedure but it works only for a fixed number of lists. I would like to implement a procedure for a variable number of lists which contains a variable numbe rof elements.


proc generation_foreach {} {

global list_1 list_2 list_3 list_4

set number_combi 0
foreach element_list_1 $list_1 {
foreach element_list_2 $list_2 {
foreach element_list_3 $list_3 {
foreach element_list_4 $list_4 {
puts "$element_list_1 $element_list_2 $element_list_3 $element_list_4"
}
}
}
}


return 0
}




Can someone help me ?

Thanking advanced.


Pierre
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top