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

Henning Thielemann lemming at henning-thielemann.de
Wed May 23 09:30:49 EDT 2007


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] ?


More information about the Haskell-Cafe mailing list