Tcl Library Source Code

Bounty program for improvements to Tcl and certain Tcl packages.

[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


math::combinatorics - Combinatorial functions in the Tcl Math Library

Table Of Contents


package require Tcl 8.2
package require math ?1.2.3?
package require Tcl 8.6
package require TclOO
package require math::combinatorics ?2.0?

::math::ln_Gamma z
::math::factorial x
::math::choose n k
::math::Beta z w
::math::combinatorics::permutations n
::math::combinatorics::variations n k
::math::combinatorics::combinations n k
::math::combinatorics::derangements n
::math::combinatorics::catalan n
::math::combinatorics::firstStirling n m
::math::combinatorics::secondStirling n m
::math::combinatorics::partitionP n
::math::combinatorics::list-permutations n
::math::combinatorics::list-variations n k
::math::combinatorics::list-combinations n k
::math::combinatorics::list-derangements n
::math::combinatorics::list-powerset n
::math::combinatorics::permutationObj new/create NAME n
$perm next
$perm reset
$perm setElements elements
$perm setElements
::math::combinatorics::combinationObj new/create NAME n k
$combin next
$combin reset
$combin setElements elements
$combin setElements


The math package contains implementations of several functions useful in combinatorial problems. The math::combinatorics extends the collections based on features in Tcl 8.6. Note: the meaning of the partitionP function, Catalan and Stirling numbers is explained on the MathWorld website


Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category math of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.