title: How to check if a value exists in a list in smlnj
body: <p>I'm working on some homework and I need to create a function that checks if a value exists in a list. If it does it will return true, otherwise it returns false. I have an idea of how to do it but I keep getting errors. I think it may be due to my lack of knowledge of syntax and style as this is my first time coding in sml. </p>
  
  <p>I created the function exist and am passing a value and list in as a tuple.</p>
  
  <pre><code>fun exist (x, []) =     
  if x = hd ([]) then true        
  else if x  = tl ([]) then true    
  else false;
  </code></pre>
  
  <p>Sorry if this code is laughably incorrect but I get the error message:<br>
  " stdIn:2.6 Warning: calling polyEqual<br>
  stdIn:3.11 Warning: calling polyEqual<br>
  stdIn:1.6-4.11 Warning: match nonexhaustive
            (x,nil) => ...<br>
  val exist = fn : ''a list * 'b list -> bool "</p>
  
  <p>and I'm not really sure how to fix this. Any help would be great.</p>