title: f# programming the insert function?
body: <p>I am trying to implement a function that should inset in order using &lt;, if x exists in S, then S is returned unchanged. The code I wrote below does not output as intended. If I have a set S = [2; 4] and x = [4; 6]. The expected output should be 
  [2; 4; 6] where the code below outputs [2; 4; 7]. Any help to fix the issue is appreciated. Thank you.</p>
  
  <pre><code>let rec insert x S =
      match S with
      |[] -&gt; x
      |e::rest -&gt; e::(insert S rest)
  </code></pre>