Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Partition Function

  1. Nov 25, 2005 #1


    User Avatar

    Hi everyone,

    I am trying to define a function partition in Haskell that takes in an integer as an argument and returns a list of all possible positive integers that would sum to the input, ie

    partition 4 = [[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]]

    The function (formally defined) can be found here

    From the outset it looks like i'll need to increment and decrement different variables on each recursive call, but have no idea where to start. Sorry if this seems trivial, but i think it's rather difficult for a beginners tutorial :)

    Thanks for your help
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you help with the solution or looking for help too?
Draft saved Draft deleted

Similar Discussions: Partition Function
  1. Partitioning problem (Replies: 2)

  2. Goldbach Partitions (Replies: 12)

  3. Cosets / Partitions (Replies: 4)