MathGroup Archive 1998

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

Search the Archive

Re: Permutations.


Hi Alan,

In[1]:= <<DiscreteMath`Combinatorica` In[2]:= KPermutations[li_,n_]:=
  Flatten[Outer[Part,KSubsets[li,n],Permutations[Range[n]],1],1]

Jurgen


"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: Re: Bug in Calculus`DiracDelta`
  • Next by Date: Re: Bivariate Normal Distributions -- can they be estimated in my lifetime?
  • Previous by thread: Permutations.
  • Next by thread: Re: Permutations.