[Haskell-cafe] List algorithm
Henning Thielemann
lemming at henning-thielemann.de
Tue May 22 07:10:31 EDT 2007
On Mon, 21 May 2007, Steffen Mazanek wrote:
> is there an efficient algorithm that takes two positive numbers n and m and
> that computes all lists l of numbers 0<x<=n such that sum l = m?
>
> For instance
> alg 5 1 = [[1]]
> alg 5 2 = [[1,1],[2]]
> alg 5 3 = [[1,1,1],[1,2],[2,1],[3]]
> ...
http://darcs.haskell.org/htam/src/Combinatorics/Partitions.hs
alg = flip partitionsDec
More information about the Haskell-Cafe
mailing list