MathGroup Archive 2006

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

Search the Archive

Re: Listing the partitions of a set

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65317] Re: [mg65282] Listing the partitions of a set
  • From: "Adriano Pascoletti" <pascolet at dimi.uniud.it>
  • Date: Sun, 26 Mar 2006 05:44:00 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

 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: Listing the partitions of a set
  • Next by Date: Re: Problem with Infinite products
  • Previous by thread: Re: Listing the partitions of a set
  • Next by thread: Re: Re: Listing the partitions of a set