"Steffen Mazanek" <[EMAIL PROTECTED]> writes:

> alg 5 1 = [[1]]
> alg 5 2 = [[1,1],[2]]
> alg 5 3 = [[1,1,1],[1,2],[2,1],[3]]

Would this be better?

alg n m =
    case signum m of
      -1 -> []
      0 -> [[]]
      1 -> [ x : xs | x <- [1..n], xs <- alg n (m - x) ]

-- Mark

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to