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

• To: mathgroup at smc.vnet.net
• Subject: [mg49682] Re: Q: extract all k-tuple from a list of n elements
• Date: Tue, 27 Jul 2004 07:01:33 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On 7/26/04 at 4:01 AM, klaus.duellmann at arcor.de (Klaus Duellmann)
wrote:

>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.

Take a look at the function KSubsets in the package DiscreteMath`Combinatorica`

For example

<< "DiscreteMath`Combinatorica`";
n = 5;
Flatten[Table[{i, j, k},
{i, 1, n - 2}, {j, i + 1,
n - 1}, {k, j + 1, n}],
2] == KSubsets[Range[5], 3]

True
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: extract all k-tuple from a list of n elements
• Next by Date: Re: Slow LinearSolve.
• Previous by thread: Re: Q: extract all k-tuple from a list of n elements
• Next by thread: RE: Q: extract all k-tuple from a list of n elements