MathGroup Archive 2007

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

Search the Archive

Re: Combination List


Bruno Campanini wrote:
> I know combinations of 4 elements taken 3 by 3 is 4,
> that is Binomial[4,3] = 4
> How can I get the list:
> 1 2 3 
> 1 2 4
> 1 3 4
> 1 4 2
--^^^^^
I believe the last line is a typo (otherwise your request does not make 
any sense).

> The same way I get permuations list from Permutations[{...}]
> ???
> 
> Bruno
> 

What you are looking for is the list of all subsets of exactly 3 
elements. The built in function *Subsets* with its second argument set 
to {3} will do what you want.

In[1]:=
lst = {1, 2, 3, 4};
Subsets[lst, {3}]

Out[2]=
{{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}}

Regards,
Jean-Marc


  • Prev by Date: Re: Review Unsaved on Mac system
  • Next by Date: Re: Combination List
  • Previous by thread: Re: Combination List
  • Next by thread: Re: Combination List