title: Summation in functional programming
body: <p>I was searching in the web for exclusion-Inclusion principle, what i have found is this:</p>
  
  <p><a href="https://i.stack.imgur.com/g4JlE.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g4JlE.gif" alt="Formula"></a><br>
  <sub>(from MathWorld - A Wolfram Web Resource: <a href="http://mathworld.wolfram.com/images/equations/Inclusion-ExclusionPrinciple/NumberedEquation3.gif" rel="nofollow noreferrer">wolfram.com</a>)</sub>  </p>
  
  <p><a href="http://mathworld.wolfram.com/Inclusion-ExclusionPrinciple.html" rel="nofollow noreferrer">http://mathworld.wolfram.com/Inclusion-ExclusionPrinciple.html</a></p>
  
  <p>I doesn't matter if you don't understand the formula, in fact, what i need is to implement this:</p>
  
  <p><a href="https://i.stack.imgur.com/1NS0V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1NS0V.png" alt="enter image description here"></a></p>
  
  <p>For example, the input is: </p>
  
  <blockquote>
    <p><code>(summation (list 1 2) 3)</code>
      Where (list 1 2) is i and j and 3 is the limit of the sum n.</p>
  </blockquote>
  
  <p>(n had to be up the sigma but...)</p>
  
  <p>Then, the output of formula, in Scheme will be: </p>
  
  <blockquote>
    <p>(list (list 1 2) (list 1 3) (list 2 3))</p>
  </blockquote>
  
  <p>How can i implemment this in Scheme or in Haskell? (sorry for my English).</p>