INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

tcl combinations of lists

tcl combinations of lists

(OP)
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
 

RE: tcl combinations of lists

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.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close