[Haskell-cafe] Re: partitions of a multiset

2007-07-25 Thread DavidA
It seems to me (unless I've missed something?) that this method generates the power set of the original multiset (i.e. all subsets) rather than partitions.  Oops, sorry, wasn't concentrating. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: partitions of a multiset

2007-07-24 Thread Brent Yorgey
On 7/23/07, DavidA [EMAIL PROTECTED] wrote: Here's the approach I would try. 1. Use Data.List.group to group your multiset, eg [1,1,2] - [[1,1],[2]] 2. Now apply your partitions function to each of the groups [[1,1],[2]] - [ [([1,1],[]), ([1],[1]), ([],[1,1])], [([2],[]), ([],[2])] ] (Actually

Re: [Haskell-cafe] Re: partitions of a multiset

2007-07-24 Thread Pekka Karjalainen
On 7/24/07, Brent Yorgey [EMAIL PROTECTED] wrote: I'm not sure what a formal mathematical definition would be off the top of my head; but in Haskell, given a list L :: [a], I'm looking for all partitions P :: [[a]] where (sort . concat $ P) == (sort L). Here is quick attempt that requires Ord

Re: [Haskell-cafe] Re: partitions of a multiset

2007-07-24 Thread Brent Yorgey
On 7/24/07, Pekka Karjalainen [EMAIL PROTECTED] wrote: On 7/24/07, Brent Yorgey [EMAIL PROTECTED] wrote: given a list L :: [a], I'm looking for all partitions P :: [[a]] where (sort . concat $ P) == (sort L). Here is quick attempt that requires Ord [a] and expects a sorted list. It may very

[Haskell-cafe] Re: partitions of a multiset

2007-07-23 Thread DavidA
Here's the approach I would try. 1. Use Data.List.group to group your multiset, eg [1,1,2] - [[1,1],[2]] 2. Now apply your partitions function to each of the groups [[1,1],[2]] - [ [([1,1],[]), ([1],[1]), ([],[1,1])], [([2],[]), ([],[2])] ] (Actually of course, you can probably write a simpler