Oct 20, 2011 #1 batarsehf Programmer Oct 20, 2011 1 US Hello, I am new to tcl programming and I am trying to write a tcl code to do list of every possible combinations of lists to build a table: list 1 {a,b,c} 2 {d,e,f} 3 {g,h} output: a,d,g a,d,h a,e,g a,e,h a,f,g a,f,h b,d,g b,d,h ... Thanks for your help
Hello, I am new to tcl programming and I am trying to write a tcl code to do list of every possible combinations of lists to build a table: list 1 {a,b,c} 2 {d,e,f} 3 {g,h} output: a,d,g a,d,h a,e,g a,e,h a,f,g a,f,h b,d,g b,d,h ... Thanks for your help
Oct 28, 2011 #2 thacoda Programmer Nov 7, 2008 31 NL Code: set L0 {a b c}; set L1 {d e f}; set L2 {g h}; foreach n0 $L0 {foreach n1 $L1 {foreach n2 $L2 {puts "$n0 $n1 $n2 "}}} this is just one way of doing it, a more dynamic method is possible but that requires more complexity. Upvote 0 Downvote
Code: set L0 {a b c}; set L1 {d e f}; set L2 {g h}; foreach n0 $L0 {foreach n1 $L1 {foreach n2 $L2 {puts "$n0 $n1 $n2 "}}} this is just one way of doing it, a more dynamic method is possible but that requires more complexity.