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: [mg65319] Re: Listing the partitions of a set
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 26 Mar 2006 05:44:02 -0500 (EST)
  • References: <e0022d$plp$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Richard Palmer schrieb:
> 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}} .  
> 
> 
Yes, it is:

In[1]:= <<DiscreteMath`Combinatorica`

In[2]:= SetPartitions[{1,2,3,4}]
Out[2]=
{{{1,2,3,4}},{{1},{2,3,4}},{{1,2},{
     3,4}},{{1,3,4},{2}},{{1,2,3},{4}},{{1,4},{2,3}},{{1,2,4},{3}},{{
     1,3},{2,4}},{{1},{2},{3,4}},{{1},{2,3},{4}},{{1},{2,
     4},{3}},{{1,2},{3},{4}},{{1,3},{2},{4}},{{1,4},{2},{3}},{{1},{2},{3},{4}}}

In[3]:= %//Length
Out[3]= 15


  • Prev by Date: Re: Different font behavior between kernel and front-end
  • Next by Date: Re: Listing the partitions of a set
  • Previous by thread: Re: Listing the partitions of a set
  • Next by thread: Re: Listing the partitions of a set