Skip to content

Instantly share code, notes, and snippets.

@pjotrp
Created June 26, 2010 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjotrp/453917 to your computer and use it in GitHub Desktop.
Save pjotrp/453917 to your computer and use it in GitHub Desktop.
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