Subtract ordered lists
You can merge all the testing into one match expression:

let rec subtract_list xs ys =
  match xs, ys with 
  | [], _ -&gt; []
  | _, [] -&gt; xs
  | x :: xs', y :: ys' when x = y -&gt;
      subtract_list xs' ys'
  | x :: xs', _ -&gt;
      x :: (subtract_list xs' ys)


This also gets rid of the if expression.