1
2
3
4
5
6
7
main = putStr $ unlines $ map (unlines . map (bou!!))
  $ partitions 50 where
  bou = iterate ("[]"++) ""

partitions n = [1..n] >>= f n n  where
  f 0 _ m = return $ replicate m 1
  f n p m = [x:xs| let p' = min (n-m+1) p, x <- [p',p'-1..(n+m-1)`div`m], xs <- f (n-x) x (m-1)]