title: Rotate list in OCaml
body: <p>I want to write a function <code>rotate n l</code> that returns a new list containing the same elements as <code>l</code>, "rotated" <code>n</code> times to the right. For example,</p>
  
  <blockquote>
    <p><code>rotate 0 [1;2;3;4]</code> should return <code>[1;2;3;4]</code><br>
    <code>rotate 1 [1;2;3;4]</code> should return <code>[4;1;2;3]</code><br>
    <code>rotate 2 [1;2;3;4]</code> should return <code>[3;4;1;2]</code><br>
    <code>rotate 3 [1;2;3;4]</code> should return <code>[2;3;4;1]</code><br>
    <code>rotate 4 [1;2;3;4]</code> should return <code>[1;2;3;4]</code><br>
    etc.  </p>
  </blockquote>
  
  <p>The behavior of <code>rotate n</code> for <code>n</code> less than 0 should be the same as for <code>n</code> equal to 0.
  I want to write this without using the list concatenation operator <code>@</code> from <code>Pervasives</code>.</p>
  
  <p><strong>Update:</strong> Here is the rotation function I wrote:</p>
  
  <pre><code>let rot1 l =
    let rec iterate acc = function
        [] -&gt; []
      | [x] -&gt; x :: List.rev acc
      | x :: l -&gt; iterate (x :: acc) l
    in
    iterate [] l;;
  </code></pre>
  
  <p>But I want it to do the same thing without using <code>List.rev</code>.
  Is there a way to do this?</p>