Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
object StripComments {
def stripComments1(s:String, markers:String =";#")=s takeWhile (!markers.contains(_)) trim
// using regex and pattern matching
def stripComments2(s:String, markers:String =";#")={
val R=("(.*?)[" + markers + "].*").r
(s match {
case R(line) => line
case _ => s
}) trim
}
def print(s:String)={
println("'"+s+"' =>")
println(" '"+stripComments1(s)+"'")
println(" '"+stripComments2(s)+"'")
}
def main(args: Array[String]): Unit = {
print("apples, pears # and bananas")
print("apples, pears ; and bananas")
}
}