Binary search in functional-style Scala
the high &lt;= low part does not involve x and could be pulled out of the case. The rest is fine IMHO.

One remark: the -1 return in the error-case is a bit of a smell - why not return Option[Int] instead?

And finally: I think you don't need mid as an argument - as you guard for low &gt; high anyway you can as easily compute it inside your inner function and make the calls a bit more readable (only low and high)

Could look like this

  type Index = Int

  def binarySearch(ds: Array[Double], key: Double): Option[Index] = {
      @tailrec
      def go(lo: Index, hi: Index): Option[Index] = {
        if (lo &gt; hi)
          None
        else {
          val mid: Index = lo + (hi - lo) / 2
          ds(mid) match {
            case mv if (mv == key) =&gt; Some(mid)
            case mv if (mv &lt;= key) =&gt; go(mid + 1, hi)
            case _ =&gt; go(lo, mid - 1)
          }
        }
      }
      go(0, ds.size - 1)
  }