0

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..)
user6818
  • 1,171
  • 1
  • 12
  • 27
  • Isn't there just one result, given by Partition[myList, 2]? – wxffles May 16 '13 at 01:55
  • If I understand you I believe this question is answered here: http://mathematica.stackexchange.com/q/3044/121 Can you confirm that? – Mr.Wizard May 16 '13 at 02:12
  • @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. – user6818 May 16 '13 at 16:51
  • @wxffles I don't want all subsets of size 2. I want all partitions such that all parts are of size 2. – user6818 May 16 '13 at 16:53
  • @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. – user6818 May 16 '13 at 16:56
  • @Mr.Wizard I could get Rojo's answer to work - but its like mumbo-jumbo to me who has no clue how to do programming on Mathematica! Its as good as using some package! I wish i could understand Rojo's syntax and method! – user6818 May 16 '13 at 17:00
  • @user6818 since Rojo's code is doing what you need I'm going to close this question with a link to that one, to keep things organized. I too found Rojo's function hard to understand at first, not the syntax but the underlying algorithm. He explained it here. If you have question about the syntax ask focused questions in the main chat room.. BTW, F1 will bring up help for the token at the location of the cursor, and see http://mathematica.stackexchange.com/a/3146/121 – Mr.Wizard May 16 '13 at 22:41

0 Answers0