Basic search algorithms in Scala