title: Process large lists in Haskell into a single value
body: <p>I have 2 lists of Int of equal size (roughly 10,000 elements): say x and y. I need to compute a product of the following expression for each corresponding pair of elements from the lists: x_i/(x_i+y_i), i.e. x_i and y_i are the first elements of the lists, then second, etc.</p>
  
  <p>My approaches work fine on small test cases, but ghci hangs for the larger lists. Any insight as to the cause and solution would be appreciated.</p>
  
  <p>I tried to do this with fold, zipping the lists first:</p>
  
  <pre><code>getP:: [Int] -&gt; [Int] -&gt; Double
  getP zippedCounts = foldr (\(x,y) acc -&gt; let intX = fromIntegral x
                                               intY = fromIntegral y
                                               intSum = intX + intY in
                                               (acc*(intX/intSum))) 
                            1.0
                            zippedCounts
  </code></pre>
  
  <p>I also tried recusion:</p>
  
  <pre><code>getP lst [] = 1.0
  getP [] lst = 1.0
  getP (h1:t1) (h2:t2) = ((fromIntegral h1) / ((fromIntegral h1) + (fromIntegral h2))) * (getP t1 t2)
  </code></pre>
  
  <p>As well as list comprehension:</p>
  
  <pre><code>getP lst1 lst2 = (product [((fromIntegral x) / ((fromIntegral x) + (fromIntegral y)))|x &lt;- lst1, y &lt;- lst2])
  </code></pre>