Combinations Dispositions Permutations TREE
- To: mathgroup at smc.vnet.net
- Subject: [mg108698] Combinations Dispositions Permutations TREE
- From: Lele <emanuele.tormene at gmail.com>
- Date: Sun, 28 Mar 2010 04:06:53 -0500 (EST)
Given a list l of n objects, I want to choose k elements, with or without repetitions I wrote some functions to find the number and the elements of dispositions Disp[n_, k_] := n!/(n - k)!; ElDisp[l_, k_] := Permutations[l, {k}]; DispRip[n_, k_] := n^k; ElDispRip[l_, k_] := Tuples[l, k]; permutations Perm[n_] := Disp[n, n]; ElPerm[l_] := Permutations[l, {Part[Dimensions[l], 1]}]; combinations Comb[n_, k_] := Disp[n, k]/Perm[k]; ElComb[l_, k_] := Subsets[l, {k}]; CombRip[n_, k_] := (n + k - 1)!/((k! (n - 1)!)); ElCombRip[l_, k_] := (m = ElDispRip[l, k]; d = Length[m]; For[i = 1, i < d, m[[i]] = Sort[m[[i]]], i++]; Union[m]); 1) I am sure it is possible to write my functions really better 2) I would like to write a function able to draw a tree representing the path going through every k-th step of "fishing" into the list (for every function). For example, given the l={a,b,c} , k=2, I would like to draw a DispositionTree[l,k] a -- b / \ c / --b -- a \ \ c \ c -- a \ b Thanks, Lele (I am sorry for my english, my code and my ignorance)