title: Counting how many elements in a sorted list, that are larger than a given predicate
body: <p>I'm trying to create a function that finds how many elements that are bigger than the first element divided by <code>2</code> in a given sorted list. For example given a list <code>[3,3,4,5,6,7,8,9,11]</code>, first element is <code>3</code>, numbers larger divided by <code>2</code> are <code>7,8,9,11</code> so function returns <code>4</code>.</p>
  
  <p>I have done this so far but it doesn't work. The <code>a</code> element is the first of the list and is given in order to be easier.</p>
  
  <pre><code>fun findlarger a [] =
    | findlarger [] = 0
    | findlarger [x] = 0
    | findlarger (x::xs) =
      let
        val a = ref a;
      in
        if !a &lt; x/2 then length (xs) + 1 else findlarger (a, xs)
      end
  </code></pre>