MathGroup Archive 1998

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

Search the Archive

Re: Permutations.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14792] Re: [mg14771] Permutations.
  • From: Robert Pratt <rpratt at math.unc.edu>
  • Date: Wed, 18 Nov 1998 01:28:55 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

Alan,

Just combine Permutations and KSubsets as follows.

<<DiscreteMath`Combinatorica`

KPermutations[lis_List,k_]:=Flatten[Map[Permutations,KSubsets[lis,k]],1]

By the way, as a point of clarification, note that you have the phrases
"order counts" and "order not counting" reversed in your message below.

Rob Pratt
Department of Mathematics
The University of North Carolina at Chapel Hill CB# 3250, 331 Phillips
Hall
Chapel Hill, NC  27599-3250

rpratt at math.unc.edu

http://www.math.unc.edu/Grads/rpratt/

On Sat, 14 Nov 1998, Alan W.Hopper wrote:

> Greetings,
> 
> 
> For the combinations of n objects taken k at a time, (where order counts
> and there is no duplication), the function KSubsets is the one to use.
> e.g.
>       In[1]:= <<DiscreteMath`Combinatorica`
> 
>       In[2]:= Table[KSubsets[{a,b,c,d}, k], {k, 4}]
> 
>      Out[3]= {{{a}, {b}, {c}, {d}},
>               {{a,b}, {a,c}, {b,c}, {b,d}, {c,d}},
>               {{a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}},
>               {{a,b,c,d}}}
> 
> But likewise in wanting to find all the permutation subsets (with no 
> duplication and order not counting), of a numerical or symbolic list,
> there does not seem to be a function anywhere (including the packages),
> to achieve this goal.
>  
> (By n!/(n-k)!, there will be be; 4, 12, 24, 24  permutations  taken k =
> 1, 2, 3, 4  at a time, for a 4 element list).
> 
> The built-in function Permutations and also LexicographicPermutations 
> (from Combinatorica) do not take a second argument, as KSubsets does,
> and so only the (n, k=n) permutations (24 in the example ) can be
> found.
> 
> I would appreciate some assistance to find a way to generate all of the
> permutation subsets, in List, Table or Column form.
> 
> 
> Alan W.Hopper
> awhopper at hermes.net.au



  • Prev by Date: simulating DSP quantization in Mathematica
  • Next by Date: Symbolic Matrix Manipulations
  • Previous by thread: Re: Permutations.
  • Next by thread: Re: Permutations.