title: How to get a value from a for loop in OCaml
body: <p>I written the following code to randomly select items n items from a list and place the selections in a new list
  The code is below </p>
  
  <pre><code>let random_extract list n =
      let l =  ((List.length list)- 1) 
      and acc = []  in
      for i = 1 to n do 
          (List.nth list (Random.int l) ) :: acc  (* Line 447 *)
      done;
      acc
  ;;
  </code></pre>
  
  <p>When I load the file that contains this code I get the following error</p>
  
  <pre><code>File "all_code.ml", line 447, characters 2-40:
  Warning 10: this expression should have type unit.
  val random_extract : 'a list -&gt; int -&gt; 'b list = &lt;fun&gt;
  </code></pre>
  
  <p>Two questions , 
  Question 1: what does this warning mean. </p>
  
  <p>Secondly when I run this function I dont get the list expected but an empty List.</p>
  
  <p>Question 2: how do I get the value of acc from inside the for loop</p>