title: Composition algorithm in Javascript to return all possible compositions of a number
body: <p><strong>Edit:</strong></p>
  
  <p>I need to implement composition algorithm in Javascript, where the result would be the same as <a href="http://en.wikipedia.org/wiki/Composition_%28number_theory%29#Examples" rel="nofollow">the figure on the right in Wikipedia</a>.With a given number (<code>n</code>), the function would be able to return all possible separations, e.g.</p>
  
  <pre><code>2: [1,1], [2] (2 sets)
  3: [1,1,1], [1,2], [2,1], [3] (4 sets)
  4: [1,1,1,1], [1,1,2], [1,2,1], [2,1,1], [2,2], [3,1], [1,3], [4] (8 sets)
  </code></pre>
  
  <p>Ideally it should be a function accept and execute callback <code>2^(n-1)</code> times. I will accept answers in any language I could understand (and rewrite from). Thanks!</p>