[Haskell-beginners] partition a list in all possible ways
Bryce Verdier
bryceverdier at gmail.com
Tue Apr 26 20:34:19 CEST 2011
Take a look at Data.List and the function subsequences.
http://www.haskell.org/ghc/docs/7.0.2/html/libraries/base-4.3.1.0/Data-List.html#v:subsequences
The only thing you'll need to figure out after that is how to transform
all of those strings to a list data type.
I hope this helps,
Bryce
On 04/26/2011 11:10 AM, I. J. Kennedy wrote:
> I'm looking for a function [a] -> [[[a]]] that will partition a list
> into non-empty pieces in all possible ways.
> For example
> f [1,2,3,4] = [[[1],[2],[3],[4]], [[1],[2],[3,4]], [[1],[2,3],[4]],
> [[1],[2,3,4]], [[1,2],[3],[4]], [[1,2],[3,4]], [[1,2,3],[4]], [[1,2,3,4]]]
> Perhaps this is a well-known function to experts, but not to me.
> Hoogle doesn't seem to have anything with this signature.
> Thanks,
> Jack
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110426/a938089c/attachment.htm>
More information about the Beginners
mailing list