title: OCaml: swapping elements in a list
body: <p>I'm wondering how can I write a function that divides a given list to sublists in a given point, swaps these sublists and returns a resulting list. </p>
  
  <p>For example:</p>
  
  <pre><code>swap([1;3;5;6],2) =&gt; [5;6;1;3]
  </code></pre>
  
  <p>I suppose that the code that I developed is correct?</p>
  
  <pre><code>let rec swap (l,n) =
  let rec loop t (count,laux)  =
              match t with
              |  h::t when count &lt; n -&gt; loop t (count+1, h::laux)
              |  h::t -&gt;   h::t@  List.rev laux
              | []-&gt;[]
  in
      loop l (0,[]) 
  </code></pre>
  
  <p>;;</p>