title: Random number generator and pattern matching - OCaml
body: <p>In order to learn about pattern matching, I'm currently trying to generate a number from 1 to 3 in Ocaml and write it to stdout.</p>
  
  <p>This is what I wrote so far (function with empty argument):</p>
  
  <pre><code>let random_compchoice () = match Random.int 3 with
      | 1 -&gt; "1"
      | 2 -&gt; "2"
      | 3 -&gt; "3"
      | _ -&gt; "Error"
  ;;
  
  Printf.printf "The option is %s\n" random_compchoice;;
  </code></pre>
  
  <p>However this triggers: </p>
  
  <pre><code>**Error**: This expression has type unit -&gt; string
         but an expression was expected of type string
  </code></pre>
  
  <p>But, if I do this:</p>
  
  <pre><code>let random_compchoice = match Random.int 3 with
      | 1 -&gt; "1"
      | 2 -&gt; "2"
      | 3 -&gt; "3"
      | _ -&gt; "Error"
  ;;
  
  Printf.printf "The option is %s\n" random_compchoice;;
  </code></pre>
  
  <p>It compiles but always defaults to:</p>
  
  <pre><code>The option is Error
  </code></pre>
  
  <p>Any ideas of what I am missing there? Thanks in advance.
  (Also not sure that it is possible to start with 1 as first 'case' and not 0).</p>