title: OCaml pattern matching on integers
body: <p>I have an assignment to fill in the following code stub:</p>
  
  <pre><code>let quad (x,y) = 
    match (x,y) with 
    | ... -&gt; ...
    ...
  </code></pre>
  
  <p>where the <code>quad</code> function is supposed to take a tuple of ints as its argument, and return an algebraic data type representing the quadrant that the coordinates lie in.  I know exactly how to do it using if-clauses, but how would one do this using matching?  Is there a way to match integers with their sign?  I know I could even do it by matching on the value of a sign function.  I could write a function <code>sign</code> such that <code>sign 10 = 1</code> and <code>sign (-10) = -1</code> and so on, and then match on these values, but according to the code stub I shouldn't even do that.  Any hint on how to accomplish this?  Should I only do my matching on 0, and then if it's not 0 use if-clauses after the <code>-&gt;</code>?  Or is there some use of matching that can detect positive and negative integers?</p>