Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permutations & Combinations in Tcl??

Status
Not open for further replies.

RajVerma

Programmer
Jun 11, 2003
62
DE
dear all,

are there any built-in functions in Tcl where we can achieve nPr and nCr, i.e, permutations and combinations. if not what is the best way to do? cud any one give me some info where we can find this kind of recursive procedures.

for example, if I give 3 as input to the proc, I want to get 1,12,123,13,2,23,3 as output. that means for n I have pow(2,n)-1 combinations.

thanx a lot.

Raj.
 
The Tcler's Wiki ( is a great place to look for utilities like this. Read through some of the "welcome" pages to get a feel for the place, and then just start searching. I quickly came up with the following page: "Combinatorial mathematics functions," You should be able to modify the code there to your needs fairly easily.

- Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top