Re: Re: Listing the partitions of a set

*To*: mathgroup at smc.vnet.net*Subject*: [mg65325] Re: [mg65317] Re: [mg65282] Listing the partitions of a set*From*: "Adriano Pascoletti" <pascolet at dimi.uniud.it>*Date*: Mon, 27 Mar 2006 06:55:51 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

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 >