Skip to content

Instantly share code, notes, and snippets.

@pjotrp
Created June 18, 2010 06:36
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/443337 to your computer and use it in GitHub Desktop.
Save pjotrp/443337 to your computer and use it in GitHub Desktop.
val Gap1 = '-'
def splitSimplePass1(seq: List[Char], gap: Char): List[List[Char]] = {
def isMatch(inGapped: Boolean, c: Char) = {
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 :: splitSimplePass1(tail, gap)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment