Created
August 6, 2016 20:01
-
-
Save bchapuis/97c99bc187eebfa5b75033a04aebdcbb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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