Extract Element and its Followers from List
The current version of the function does not take into account the cases:


(as @itsbruce mentioned) if the list starts with a value other than '1'
if there are consecutive '1's


The second case is using wildcards, but instead it'd better directly match a list starting with '1':

case 1 :: tail =&gt; {
  // we take only the following elements different from 1
  val followers = tail.takeWhile(_ != 1)
  // we drop the 'followers' prefix for the recursive call
  val remainder = tail.drop(followers.size)
  (1 :: followers) :: leadingOnesGroup(remainder)
}


Of course, this block can be shortened to two lines only, but it will be less readable.

Since it is not clear how to process lists that do not start with '1', a generic matcher with an explicit exception can be added:

case _ =&gt; throw new IllegalArgumentException("Unexpected start of list: " + xs)