Created
June 26, 2010 09:10
-
-
Save pjotrp/453917 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
case class Symbol() | |
case object Gap2 extends Symbol | |
case object A extends Symbol | |
case object G extends Symbol | |
case object C extends Symbol | |
case object T extends Symbol | |
def splitSimplePass2(seq: List[Symbol], gap: Symbol): List[List[Symbol]] = { | |
def isMatch(inGapped: Boolean, c: Symbol) = { | |
if (inGapped) | |
c == gap | |
else | |
c != gap | |
} | |
val isGap = (seq(0) == gap) | |
val s = seq.takeWhile{ isMatch(isGap,_) } | |
val tail = seq.takeRight(seq.length - s.length) | |
tail match { | |
case Nil => s :: Nil | |
case _ => s :: splitSimplePass2(tail, gap) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment