. def pack(list: List[Char]): List[List[Char]] = {   def checkNext(a: List[List[Char]], prev: Char, l: List[Char] ): List[List[Char]] = {     if (!l.nonEmpty) a     else {       val res = if (prev==l.head) 