title: Pair swap elements in list using Ocaml
body: <p>I am a Ocaml beginner, and am not able to understand tail recursiveness or list iteration. How can we iterate through list is 2s and swap the pairs?</p>
  
  <pre><code>let rec swap = function
  | a :: (b :: _ as t) -&gt; b::a::swap t | smaller -&gt; smaller;;
  let newlist = swap [1;2;3;4];;
  List.iter print_int newlist;
  </code></pre>
  
  <p>For example, 1234, the swap function is swapping 1 and 2, and then the list head is still at 2, and its swapping 2 and 3 whereas it should be at 3 and swapping 3 and 4.</p>