Hi everyone,(adsbygoogle = window.adsbygoogle || []).push({});

I am trying to define a functionpartitionin 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

http://en.wikipedia.org/wiki/Partition_function_(number_theory)

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

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Partition Function

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**