Skip to content

Instantly share code, notes, and snippets.

@taku0
Created June 11, 2014 15:35
Show Gist options
  • Select an option

  • Save taku0/0c4e6759df96005b298e to your computer and use it in GitHub Desktop.

Select an option

Save taku0/0c4e6759df96005b298e to your computer and use it in GitHub Desktop.
import Control.Applicative
part n 1 = [[n]]
part n k = [0..n] >>= \i -> (i:) <$> part (n - i) (k -1)
main :: IO ()
main = mapM_ print (part 7 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment