title: Finding Max/Min number in list in Ocaml
body: <p>I just began to learn Ocaml recently and now just started to practice some codes.
  In this case, I tried to find a maximum number in a list but it keeps return me an error message.</p>
  
  <pre><code>let max: int list -&gt; int
  = fun lst -&gt;
  match lst with
   |[] -&gt; 0
   |h::[] -&gt; h
   |h::t -&gt; let a = max t in
              if h &lt; a then h
              else
               a;;
  </code></pre>
  
  <p>Ocaml keeps saying:</p>
  
  <blockquote>
    <p>Error: This expression has type int list -> int list but an expression was expected of type int.</p>
  </blockquote>
  
  <p>I don't understand why a is an int list though I claimed it as a max t which is a function that makes int list into int... Thanks for yout help.</p>