title: OCaml: Removing consecutive duplicates from a list without recursion
body: <p>I'm supposed to remove consecutive duplicates from an <code>int list</code> without using recursion and using only <code>List.fold</code>, <code>map</code>, <code>filter</code>, <code>fold_left</code>, <code>fold_right</code>. </p>
  
  <p>I almost got it, but the problem with my code is that it checks if each element equals the 2nd element, and not the next element.</p>
  
  <p>For example if <code>let z = int list [3;1;4;5;5;1;1]</code> my code will return <code>[3;4;5]</code> and not <code>[3;1;4;5;1]</code>. I'm not sure how to change it so <code>filter</code> uses a dynamically changing list parameter and not simply the original one (so it doesn't compare each element to the second element (1 in this case) each time):</p>
  
  <pre><code>let dupe (ls: int list) : int list =
      List.filter (fun x -&gt; if List.length ls = 0 then true else if x = List.hd (List.tl xs) then false else true) ls
  </code></pre>