MathGroup Archive 2006

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

Search the Archive

Re: Re: Listing the partitions of a set


Reading my previous message I realize I answered a different question: subsets of a given set, not its partitions. Sorry.
Adriano Pascoletti

Adriano Pascoletti wrote ..
>  Richard Palmer wrote:
>  > Is there a simple way to list the partitions of a set?  For example,
> > there are 15 partitions on a set of 4 elements.  {{{1, 2, 3, 4}}, {1,
> {2, 3,4}},
> > > {{1, 3, 4}, 2}, {{1, 2, 4}, 3}, {{1, 2, 3},    4}, {{1, 2}, {3, 4}},
> > {{1, 3}, {2, 4}}, {{1, 4}, {2, 3}}, {1, 2, {3, 4}}, {1, 3, {2, 4}}, {1,
> 4,
> > {2,3}}, {2, 3, {1, 4}}, {2,    4, {1, 3}}, {3, 4, {1, 2}}, {1, 2, 3,
> 4}}
> > .  
> 
> Richard,
> Mathematica 5.1 introduced Subsets:
> In[1]:=
> Subsets[{1,2,3,4}]//Rest
> 
> Out[1]=
> {{1},{2},{3},{4},{1,2},{1,3},{1,4},{2,3},{2,4},{3,4},{1,2,3},{1,2,4},{
>   1,3,4},{2,3,4},{1,2,3,4}}
> 
> One can get the same result with Distribute (an idea of I. Vardi, IIRC):
> 
> In[2]:=
> Distribute[{{},{#}}&/@Range[4],List,List,List,Join]//Sort//Rest
> 
> Out[2]=
> {{1},{2},{3},{4},{1,2},{1,3},{1,4},{2,3},{2,4},{3,4},{1,2,3},{1,2,4},{
>   1,3,4},{2,3,4},{1,2,3,4}}
> 
> 
> Adriano Pascoletti
> 


  • Prev by Date: Re: About subscripts
  • Next by Date: Re: Writing prime factor decomposision in conventional form
  • Previous by thread: Re: Listing the partitions of a set
  • Next by thread: Plot equations and inequalities together