title: How do I use List.fold_left?
body: <p>I'm still trying to understand how <code>fold_left</code> exactly works. Does it iterate through the list like <code>List.iter</code>? Or is there just something else wrong with my code? I'm thinking that e is the element in the list (so it's a tuple) and <code>fst e</code> takes the first element of the tuple and <code>snd e</code> takes the second element in the tuple.</p>
  
  <pre><code>let rec pow x n = 
      if n &lt; 0 then
          0
      else if n = 0 then
          1
      else 
          x * pow x (n - 1);;    
  
  let polynomial lst = function
      | x -&gt; List.fold_left (fun e -&gt; (fst e) * (pow x (snd e))) 1 lst;;
  </code></pre>
  
  <p>lst is a list of tuples where each tuple has two integers and makes a polynomial function, so polynomial is supposed to return a function. So an example of what should happen is this</p>
  
  <pre><code># let f = polynomial [3, 3; -2, 1; 5, 0];;
  val f : int -&gt; int = &lt;fun&gt;
  # f 2;; (* f is the polynomial function f(x) = 3x^3 + (-2)x + 5 *)
  - : int = 25
  </code></pre>
  
  <p>But I get this error message </p>
  
  <blockquote>
    <p>"Error: This expression has type int but an expression was expected of type 'a -> int * int".</p>
  </blockquote>