title: Folding a list in OCaml
body: <p>In OCaml, a typical fold function looks like this:</p>
  
  <pre><code>let rec fold (combine: 'a -&gt; 'b -&gt; 'b) (base: 'b) (l: 'a list) : 'b =
    begin match l with
    | [] -&gt; base
    | x :: xs -&gt; combine x (fold combine base xs)
    end
  </code></pre>
  
  <p>For those familiar with OCaml (unlike me), it should be pretty straightforward what it's doing.</p>
  
  <p>I'm writing a function that returns true when all items in the list satisfy the condition: if condition x is true for all x in some list l. However I'm implementing the function using a fold function and I'm stuck. Specifically I don't know what the list should return. I know that ideally the condition should be applied to every item in the list but I have no idea how the syntax should look. <code>x &amp;&amp; acc</code> works but it fails a very simply test (shown below)</p>
  
  <pre><code>let test () : bool =
    not (for_all (fun x -&gt; x &gt; 0) [1; 2; -5; -33; 2])
  ;; run_test "for_all: multiple elements; returns false" test
  </code></pre>
  
  <p>Here is my preliminary attempt. Any help is appreciated:</p>
  
  <pre><code>let  for_all (pred: 'a -&gt; bool) (l: 'a list) : bool =
  fold (fun(x:'a)(acc: bool)-&gt;  _?_&amp;&amp;_?_  )false l
  </code></pre>