Created
July 1, 2010 06:13
-
-
Save pjotrp/459640 to your computer and use it in GitHub Desktop.
This file contains 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
class GapSplitting3Spec extends FlatSpec with ShouldMatchers { | |
case class Symbol() | |
case object Gap extends Symbol | |
case object A extends Symbol | |
case object G extends Symbol | |
case object C extends Symbol | |
case object T extends Symbol | |
def splitSimplePass3(seq: List[Symbol]): List[List[Symbol]] = { | |
val gap = Gap | |
val isGap = (seq(0) == gap) | |
def isMatch(c : Symbol) = { if (isGap) c == gap else c != gap } | |
val s = seq.takeWhile{ isMatch } | |
val tail = seq.takeRight(seq.length - s.length) | |
tail match { | |
case Nil => s :: Nil | |
case _ => s :: splitSimplePass3(tail) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment