Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg65302] Re: [mg65282] Listing the partitions of a set
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 25 Mar 2006 05:17:37 -0500 (EST)
  • Reply-to: hanlonr at cox.net
  • Sender: owner-wri-mathgroup at wolfram.com

Needs["DiscreteMath`Combinatorica`"];

s=SetPartitions[4]

{{{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}}}

s/.{x_?NumberQ}:>x

{{{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}}


Bob Hanlon

> 
> From: Richard Palmer <mapsinc at bellatlantic.net>
To: mathgroup at smc.vnet.net
> Subject: [mg65302] [mg65282] Listing the partitions of a set
> 
> 
> 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}} .  
> 
> 
> 


  • Prev by Date: Re: Listing the partitions of a set
  • Next by Date: Re: How to sample a 2-dim. r.v. with known density function?
  • Previous by thread: Re: Listing the partitions of a set
  • Next by thread: Re: Listing the partitions of a set