z      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~    "Tuples"A fitting into a give shape. The order is lexicographic, that is,  ( sort ts == ts where ts = tuples' shape  Example:  tuples' [2,3] = M [[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3]]  positive "tuples" fitting into a give shape. # = \prod_i (m_i + 1) # = \ prod_i m_i length (width) maximum (height) length (width) maximum (height) # = (m+1) ^ len # = m ^ len      (-1)^k  A000142.  A006882.  A007318. Catalan numbers. OEIS:A000108. Catalan's triangle. OEIS:A009766.  Note: " catalanTriangle n n == catalan n G catalanTriangle n k == countStandardYoungTableaux (toPartition [n,k]) CRows of (signed) Stirling numbers of the first kind. OEIS:A008275.  Coefficients of the polinomial (x-1)*(x-2)*...*(x-n+1). + This function uses the recursion formula. ;(Signed) Stirling numbers of the first kind. OEIS:A008275.  This function uses , so it shouldn' t be used  to compute many Stirling numbers. 3(Unsigned) Stirling numbers of the first kind. See . 3Stirling numbers of the second kind. OEIS:A008277. ) This function uses an explicit formula. Bernoulli numbers. bernoulli 1 == -1%2 and bernoulli k == 0 for  k>2 and odd<. This function uses the formula involving Stirling numbers A of the second kind. Numerators: A027641, denominators: A027642. Power series expansion of  3 @1 / ( (1-x^a_1) * (1-x^a_2) * ... * (1-x^a_n) )@  Example: (coinSeries [2,3,5]) !! k is the number of ways  to pay k4 dollars with coins of two, three and five dollars. TODO: better name?   All possible ways to choose k elements from a list, without  repetitions. "Antisymmetric power" for lists. Synonym for  kSublists. All possible ways to choose k elements from a list, with repetitions.  "Symmetric power" for lists. See also Math.Combinat.Combinations.  TODO: better name? " Tensor power" for lists. Special case of :  4 tuplesFromList k xs == listTensor (replicate k xs)  See also Math.Combinat.Tuples.  TODO: better name? "Tensor product" for lists. 4Sublists of a list having given number of elements. # = binom { n } { k }. All sublists of a list. # = 2^n. CCombinations fitting into a given shape and having a given degree. ) The order is lexicographic, that is, 0 sort cs == cs where cs = combinations' shape k shape sum  -All combinations fitting into a given shape. ! Combinations of a given length. length sum "# = \binom { len+d-1 } { len-1 } #)Positive combinations of a given length. length sum $ !"#$ !"#$ !"#$ %-Integer vectors. The indexing starts from 1. &;The additional invariant enforced here is that partitions ; are monotone decreasing sequences of positive integers. '4Sorts the input, and cuts the nonpositive elements. (&Assumes that the input is decreasing. )9Checks whether the input is a partition. See the note at *! *9Note: we only check that the sequence is ordered, but we do not check for N negative elements. This can be useful when working with symmetric functions. % It may also change in the future... +,#The first element of the sequence. -The length of the sequence. ./The weight of the partition 5 (that is, the sum of the corresponding sequence). 0#The dual (or conjugate) partition. 12 Example: # elements (toPartition [5,2,1]) == % [ (1,1), (1,2), (1,3), (1,4), (1,5)  , (2,1), (2,2), (2,3), (2,4)  , (3,1)  ] 34Computes the number of " automorphisms" of a given partition. 56;Partitions of d, fitting into a given rectangle, as lists. (height,width) d 7SPartitions of d, fitting into a given rectangle. The order is again lexicographic. (height,width) d 89Partitions of d, as lists :Partitions of d. ;</All partitions fitting into a given rectangle. (height,width) =%All partitions up to a given degree. ># = \binom { h+w } { h } ?@Partitions of a multiset. A+Vector partitions. Basically a synonym for C. BC!Generates all vector partitions  (" algorithm M" in Knuth). , The order is decreasing lexicographic. %&'()*+,-./0123456789:;<=>?@ABC&)('*+,-./012345768:9;<=>?@%ABC%&'()*+,-./0123456789:;<=>?@ABC DAdds unique labels to a . EAdds unique labels to a  FGH>Attaches the depth to each node. The depth of the root is 0. IJKL:Computes the set of equivalence classes of trees (in the % sense that the leaves of a node are  unordered)  with  n = length ks% leaves where the set of heights of / the leaves matches the given set of numbers. ( The height is defined as the number of edges from the leaf to the root. TODO: better name? DEFGHIJKL LDEFGHIJK DEFGHIJKL%M;Disjoint cycle notation for permutations. Internally it is [[Int]]. NNStandard notation for permutations. Internally it is an array of the integers [1..n]. OPQ7Assumes that the input is a permutation of the numbers [1..n]. R9Checks whether the input is a permutation of the numbers [1..n]. SChecks the input. TReturns n2, where the input is a permutation of the numbers [1..n] UVWXThis is compatible with Maple's  convert(perm,'disjcyc'). YZ[Plus 1 or minus 1. \]9Action of a permutation on a set. If our permutation is  encoded with the sequence  [p1,p2,...,pn], then in the  two-line notation we have   ( 1 2 3 ... n )  ( p1 p2 p3 ... pn ) .We adopt the convention that permutations act  on the left 5 (as opposed to Knuth, where they act on the right).  Thus,  C permute pi1 (permute pi2 set) == permute (pi1 `multiply` pi2) set 3The second argument should be an array with bounds (1,n). ' The function checks the array bounds. ^The list should be of length n. _*Multiplies two permutations together. See ] for our  conventions. `The inverse permutation aA synonym for c bcPermutations of [1..n]* in lexicographic order, naive algorithm. de# = n! fA synonym for j. ghA synonym for k. ij,Generates a uniformly random permutation of [1..n].  Durstenfeld's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle). kGenerates a uniformly random cyclic permutation of [1..n].  Sattolo's algorithm (see  *http://en.wikipedia.org/wiki/Knuth_shuffle). l,Generates all permutations of a multiset. - The order is lexicographic. A synonym for n m# = \frac { (sum_i n_i) ! } { \prod_i (n_i !) } n*Generates all permutations of a multiset  (based on " algorithm L"& in Knuth; somewhat less efficient). ! The order is lexicographic. "MNOPQRSTUVWXYZ[\]^_`abcdefghijklmn"NMOPQRSTUVXWYZ[\]^_`abcdefghijklmn"MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrst An element (i,j)2 of the resulting tableau (which has shape of the F given partition) means that the vertical part of the hook has length i,  and the horizontal part j. The  hook length is thus i+j-1.  Example: - > mapM_ print $ hooks $ toPartition [5,4,1] ! [(3,5),(2,4),(2,3),(2,2),(1,1)]  [(2,4),(1,3),(1,2),(1,1)]  [(1,1)] uvwxyz*Standard Young tableaux of a given shape. " Adapted from John Stembridge,   ?http://www.math.lsa.umich.edu/~jrs/software/SFexamples/tableaux. {hook-length formula |,Semistandard Young tableaux of given shape, "naive" algorithm }Stanley'$s hook formula (cf. Fulton page 55) opqrstuvwxyz{|}opqrstuvwxyz{|}opqrstuvwxyz{|} ~Set of (i,j) pairs with i>=j>=1. Triangular arrays Generates all tableaux of size k. Effective for k<=6. o~ o~ ~ "8A binary tree with leaves and internal nodes decorated  with types a and b, respectively. .A binary tree with leaves decorated with type a.  Synonym for .  Synonym for .  Synonym for . <Generates all sequences of nested parentheses of length 2n. > Order is lexigraphic (when right parentheses are considered  smaller then left ones).  Based on " Algorithm P") in Knuth, but less efficient because of  the " idiomatic" code. NGenerates a uniformly random sequence of nested parentheses of length 2n.  Based on " Algorithm W" in Knuth. 2Nth sequence of nested parentheses of length 2n.  The order is the same as in .  Based on " Algorithm U" in Knuth. n N; should satisfy 1 <= N <= C(n) *Generates all binary trees with n nodes. $ At the moment just a synonym for . # = Catalan(n) = \frac { 1 } { n+1 } \binom { 2n } { n }. GThis is also the counting function for forests and nested parentheses. >Generates all binary trees with n nodes. The naive algorithm. 1Generates an uniformly random binary tree, using . 'Grows a uniformly random binary tree.  " Algorithm R" (Remy's procudere) in Knuth. J Nodes are decorated with odd numbers, leaves with even numbers (from the  set [0..2n]#). Uses mutable arrays internally. &!! /DEFGHIJKL Generates graphviz .dot6 file from a forest. The first argument tells whether Q to make the individual trees clustered subgraphs; the second is the name of the  graph. Generates graphviz .dot) file from a tree. The first argument is  the name of the graph.   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~              5\]      combinat-0.2.3Math.Combinat.TuplesMath.Combinat.NumbersMath.Combinat.SetsMath.Combinat.CombinationsMath.Combinat.PartitionsMath.Combinat.Trees.NaryMath.Combinat.PermutationsMath.Combinat.TableauxMath.Combinat.Tableaux.KostkaMath.Combinat.Trees.BinaryMath.Combinat.GraphvizMath.Combinat.HelperMath.Combinat.Trees Math.Combinattuples'tuples1' countTuples' countTuples1'tuplestuples1 countTuples countTuples1 binaryTuples paritySign factorialdoubleFactorialbinomial multinomialcatalancatalanTrianglesignedStirling1stArraysignedStirling1stunsignedStirling1st stirling2nd bernoulli coinSerieschoosecombinetuplesFromList listTensor kSublistscountKSublistssublists countSublists combinations'countCombinations'allCombinations' combinationscountCombinations combinations1countCombinations1 IntVector Partition mkPartitiontoPartitionUnsafe toPartition isPartition fromPartitionheightwidth heightWidthweight dualPartition_dualPartitionelements _elementscountAutomorphisms_countAutomorphisms _partitions' partitions'countPartitions' _partitions partitionscountPartitionsallPartitions' allPartitionscountAllPartitions'countAllPartitionspartitionMultisetvectorPartitions_vectorPartitionsfasc3B_algorithm_MaddUniqueLabelsTreeaddUniqueLabelsForestaddUniqueLabelsTree_addUniqueLabelsForest_labelDepthTreelabelDepthForestlabelDepthTree_labelDepthForest_ derivTreesDisjointCycles PermutationfromPermutationpermutationArraytoPermutationUnsafe isPermutation toPermutationpermutationSizefromDisjointCyclesdisjointCyclesUnsafedisjointCyclesToPermutationpermutationToDisjointCyclesisEvenPermutationisOddPermutationsignOfPermutationisCyclicPermutationpermute permuteListmultiplyinverse permutations _permutationspermutationsNaive_permutationsNaivecountPermutationsrandomPermutation_randomPermutationrandomCyclicPermutation_randomCyclicPermutationrandomPermutationDurstenfeldrandomCyclicPermutationSattolopermuteMultisetcountPermuteMultisetfasc2B_algorithm_LTableau_shapeshape dualTableaucontenthooks hookLengthsrowWordrowWordToTableau columnWordcolumnWordToTableaustandardYoungTableauxcountStandardYoungTableauxsemiStandardYoungTableauxcountSemiStandardYoungTableauxTriunTriTriangularArraytriangularArrayUnsafefromTriangularArray kostkaContent_kostkaContentkostkaTableaux_kostkaTableauxcountKostkaTableauxParen RightParen LeftParenBinTree'Leaf'Branch'BinTreeLeafBranchleafforgetNodeDecorationsparenthesesToStringstringToParenthesesforestToNestedParenthesesforestToBinaryTreenestedParenthesesToForestnestedParenthesesToForestUnsafenestedParenthesesToBinaryTree#nestedParenthesesToBinaryTreeUnsafebinaryTreeToNestedParenthesesbinaryTreeToForestnestedParenthesesrandomNestedParenthesesnthNestedParenthesescountNestedParenthesesfasc4A_algorithm_Pfasc4A_algorithm_Wfasc4A_algorithm_U binaryTreescountBinaryTreesbinaryTreesNaiverandomBinaryTreefasc4A_algorithm_RDot binTreeDot binTree'Dot forestDottreeDotdebugswapequatingreverseOrderingreverseCompare groupSortBynubOrdcountfromJust intToBool boolToIntnestunfold1unfold unfoldEitherunfoldM mapAccumMcontainers-0.3.0.0 Data.TreeTreeForest derivTrees'#randomPermutationDurstenfeldSattoloReverseHoleTableauReverseTableauHolebinom2index'deIndex'toHolenextHolereverseTableau normalize normalize' startHole enumHoleshelper newLines'newLinessizes' parenToChar subForest rootLabelNodedigraphBracket binTreeDot' binTree'Dot'