Skip to content

Instantly share code, notes, and snippets.

@pjotrp
Created July 2, 2010 07:44
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/461064 to your computer and use it in GitHub Desktop.
Save pjotrp/461064 to your computer and use it in GitHub Desktop.
case class Symbol()
case object Gap extends Symbol
case class Nucleotide() extends Symbol
case object GapN extends Nucleotide
case object A extends Nucleotide
case object G extends Nucleotide
case object C extends Nucleotide
case object T extends Nucleotide
def splitSimplePass4(seq: List[Symbol]): List[List[Symbol]] = {
val gap = GapN
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 :: splitSimplePass4(tail)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment