0
$\begingroup$

I tried the following (inspired by the answer here)

myList = {a, b, c};
Needs["Combinatorica`"];
SetPartitions[myList]

and I got this answer,

{{{a, b, c}}, {{a}, {b, c}}, {{a, b}, {c}}, {{a,c}, {b}}, {{a}, {b}, {c}}}

I checked the documentation of KSetpartitions also.

  • But where and how do I specify it if I say want only partitions in say parts of size 2 (Wick's theorem!) ? (..of course it will have to give a null result if the total number of elements of the starting set is an odd number..)
$\endgroup$
  • $\begingroup$ Isn't there just one result, given by Partition[myList, 2]? $\endgroup$ – wxffles May 16 '13 at 1:55
  • $\begingroup$ If I understand you I believe this question is answered here: mathematica.stackexchange.com/q/3044/121 Can you confirm that? $\endgroup$ – Mr.Wizard May 16 '13 at 2:12
  • $\begingroup$ @Mr.Wizard The "more economic" solution of Istvan doesn't seem to work. I tried it on a set of 4 elements and it failed. $\endgroup$ – user6818 May 16 '13 at 16:51
  • $\begingroup$ @wxffles I don't want all subsets of size 2. I want all partitions such that all parts are of size 2. $\endgroup$ – user6818 May 16 '13 at 16:53
  • $\begingroup$ @Mr.Wizard Rojo's answer looks to be what I want but I don't understand how to give the set and the part length input to it. $\endgroup$ – user6818 May 16 '13 at 16:56