Q:

How to find numbers from a list, the result are sequences based on a given number?

Want a scala method, which can find numbers from a list, the result are sequences based on a given number:
def findSeq(baseNum:Int, numbers: List[Int]): List[Int]

If no numbers fit, just return Nil:
Given:
a number: 3
a list of number: 5,9,2,4,10,6

It will return:
List(4,5,6)

Explanation:

Since the base number is 3, it will try to find 4 from the list. If found, try to find 5, then 6, until an expected one not found. The just return the found ones and sort it. Don't need to care duplicated numbers.

More test cases:
findSeq(3, Nil) === Nil
findSeq(3, List(3)) === Nil
findSeq(3, List(5,6)) === Nil

findSeq(3, List(4,5,7)) === List(4,5)
findSeq(3, List(4,7,6)) === List(4)

Looking for an elegant solution in Scala.

A:

I guess you can simply use recursion like this:
def findSeq(baseNum:Int, numbers: List[Int]): List[Int] = {
  if (numbers.contains(baseNum+1))
    (baseNum+1) :: findSeq(baseNum+1, numbers)
  else
    Nil
}

You method requires to be efficient (in some sense), or it's just for fun?
NOTE: btw, you could also use Stream, in case you don't care about efficiency. Something like this would do I guess:
def findSeq(baseNum:Int, numbers: List[Int]): List[Int] = {
  Stream.from(baseNum+1) takeWhile (numbers.contains) toList
}

