Initial Import.

This commit is contained in:
takezoe
2013-04-11 01:48:01 +09:00
parent 986a1f9a5f
commit 257f8c01b6
64 changed files with 20054 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package util
object Implicits {
implicit def extendsSeq[A](seq: Seq[A]) = new {
def splitWith(condition: (A, A) => Boolean): Seq[Seq[A]] = split(seq)(condition)
@scala.annotation.tailrec
private def split[A](list: Seq[A], result: Seq[Seq[A]] = Nil)(condition: (A, A) => Boolean): Seq[Seq[A]] = {
list match {
case x :: xs => {
xs.span(condition(x, _)) match {
case (matched, remained) => split(remained, result :+ (x :: matched))(condition)
}
}
case Nil => result
}
}
}
}