This comment is reply for 4303 shiro: comprehension大活躍。(自然数の分割). Go to thread root.
[1..100]>>=pen #4354(2007/11/23 04:13 GMT) [ Haskell ] Rating1/1=1.00
高階関数を使った版。 コード長くなった、読みづらくなった。orz
1 2 3 4 5
import List partitionNum n m = iterate f ([[]]: repeat []) !! m !! n where f xs = tail $ snd $ mapAccumL g (repeat []) [0..] where g (y:ys) i = (zipWith (++) (map (map (i:)) xs) ys, y)
Rating1/1=1.00-0+
[ reply ]
[1..100]>>=pen
#4354()
[
Haskell
]
Rating1/1=1.00
Rating1/1=1.00-0+