[Haskell-cafe] Re: efficient and/or lazy partitions of a multiset

Greg Meredith lgreg.meredith at biosimilarity.com
Wed May 23 11:54:54 EDT 2007


Henning,

i need the bi-partitions of a multiset. That is, all the ways you can split
a multiset, M, into two multisets, M1 and M2, such that M = M1
`multiset-union` M2.

Best wishes,

--greg

On 5/23/07, Henning Thielemann <lemming at henning-thielemann.de> wrote:
>
>
> On Tue, 22 May 2007, Greg Meredith wrote:
>
> > mSplitC :: [a] -> [([a], [a])] -- C for comprehension
> >
> > mSplitC [] = [([],[])]
> > mSplitC [x] = [([x],[])]
> > mSplitC (x:xs) = concat [ [(x:l,r),(l,x:r)] | (l,r) <- mSplitC xs ]
> >
> > which Matthias Radestock suggested to me.
> >
> > Note that if you only supply the empty multiset case, then you end up
> with
> > duplicates.
>
> That is ([1,2],[3]) and ([3],[1,2]) are considered the same? But you need
> always pairs not only [1,2] and [3] ?
>



-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
505 N 72nd St
Seattle, WA 98103

+1 206.650.3740

http://biosimilarity.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070523/fa8c8a33/attachment-0001.htm


More information about the Haskell-Cafe mailing list