MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

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

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

Needs["DiscreteMath`Combinatorica`"];


n=7;


k=Random[Integer,{1,n}]

KSubsets[Range[n], k]


Bob Hanlon

> In a message dated Mon, 26 Jul 2004 08:39:05 +0000 (UTC), <
> klaus.duellmann at arcor.de> writes:  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?
> 


  • Prev by Date: Re: Long function defintions
  • Next by Date: Re: Long function defintions
  • Previous by thread: 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