Re: extract all k-tuple from a list of n elements
- To: mathgroup at smc.vnet.net
- Subject: [mg49670] Re: extract all k-tuple from a list of n elements
- From: "Steve Luttrell" <steve_usenet at _removemefirst_luttrell.org.uk>
- Date: Tue, 27 Jul 2004 07:00:52 -0400 (EDT)
- References: <ce2fv9$8rm$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Here is an example of what you can do:
<< DiscreteMath`Combinatorica`
With[{n = 4, k = 3}, KSubsets[Range[n], k]]
Steve Luttrell
"Klaus Duellmann" <klaus.duellmann at arcor.de> wrote in message
news:ce2fv9$8rm$1 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
>