RE: Q: extract all k-tuple from a list of n elements

*To*: mathgroup at smc.vnet.net*Subject*: [mg49663] RE: [mg49650] Q: extract all k-tuple from a list of n elements*From*: "David Park" <djmp at earthlink.net>*Date*: Tue, 27 Jul 2004 07:00:40 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Klaus, Is this what you are looking for? Needs["DiscreteMath`Combinatorica`"]; 2-tuples from a set of 3 elements: KSubsets[{i, j, k}, 2] {{i, j}, {i, k}, {j, k}} 3-tuples from a set of 5 elements: KSubsets[{a, b, c, d, e}, 3] {{a, b, c}, {a, b, d}, {a, b, e}, {a, c, d}, {a, c, e}, {a, d, e}, {b, c, d}, {b, c, e}, {b, d, e}, {c, d, e}} David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Klaus Duellmann [mailto:klaus.duellmann at arcor.de] To: mathgroup at smc.vnet.net Question: How can I extract all k-tuple from a list of n elements (without considering permutations of the k-tuple)? Example: For the special case k=3 one solution would be Flatten[Table[{i, j, k}, {i, 1, n - 2}, {j, i + 1, n - 1}, {k, j + 1, n}], 2]; A generalization of this solution for all k >=1 would involve to create 'automatically' a table of dimension k, but how can this be implemented? Any help is appreciated. Regards, Klaus