title: Combining two functions in OCaml
body: <p>My task is to remove the duplicates from a list. To do that I have to first sort the list.</p>
  
  <p>I have written the function that sorts the list and the one that remove the 
  duplicates(once they are sorted) but I don't know how to combine them.</p>
  
  <p>Example:</p>
  
  <p>input: <code>[4;5;2;2;1;3;3]</code></p>
  
  <p>output: <code>[1;2;3;4;5]</code></p>
  
  <pre><code>let rec setify = function
      | [] -&gt; []
      | x :: l -&gt; insert x (setify l)
    and insert elem = function
      | [] -&gt; [elem]
      | x :: l -&gt; if elem &lt; x then elem :: x :: l
                  else x :: insert elem l;;
  
  let rec rem =function 
  |[] -&gt; [] 
  | x :: []-&gt; x :: [] 
  | x :: y :: rest -&gt; if x = y then rem (y :: rest) 
                      else x :: rem (y :: rest) ;;
  </code></pre>