title: Binarysearch in sml
body: <pre><code>datatype 'a tree= Leaf of 'a | Node of 'a tree * 'a * 'a tree
  
   fun binSearch (Node(left,n,right)) x =
      if x &gt; n then false  
      else if x=n then true 
      else binSearch (Node(left,n,right)) x = binSearch (right) x andalso binSearch (left) x;
  </code></pre>
  
  <p>I'm helpless. What's wrong with that code? 
  BTW it works for:</p>
  
  <pre><code>binSearch (Node (Node (Leaf 1, 2, Leaf 3), 4, Leaf 7)) 7;
  </code></pre>
  
  <p>and doesn't work for:</p>
  
  <pre><code>binSearch (Node (Node (Leaf 1, 2, Leaf 3), 4, Leaf 7)) 2;
  </code></pre>