Skip to content

Instantly share code, notes, and snippets.

@bchapuis
Created August 6, 2016 20:01
Show Gist options
  • Save bchapuis/97c99bc187eebfa5b75033a04aebdcbb to your computer and use it in GitHub Desktop.
Save bchapuis/97c99bc187eebfa5b75033a04aebdcbb to your computer and use it in GitHub Desktop.
def groupConsecutive[T](list: List[T]) : List[List[T]] = list match {
case Nil => Nil
case h::t =>
val segment = list.takeWhile(h ==)
segment :: groupConsecutiveStates(list.drop(segment.length))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment