--- a/progs/lecture5.scala Fri Dec 14 20:01:49 2018 +0000
+++ b/progs/lecture5.scala Sat Dec 15 13:46:54 2018 +0000
@@ -180,7 +180,7 @@
// input type: String
// output type: Int
-Integer.parseInt("123456")
+Integer.parseInt("123u456")
/* Note, in the previous lectures I did not show the type consraint
* I <% Seq[_] , which means that the input type I can be
@@ -241,7 +241,7 @@
val NumParser = RegexParser("[0-9]+".r)
def StringParser(s: String) = RegexParser(Regex.quote(s).r)
-println(NumParser.parse_all("12345"))
+NumParser.parse_all("12u345")
println(NumParser.parse_all("12u45"))
@@ -266,7 +266,7 @@
}
-val NumParserInt = NumParser ==> (s => s.toInt)
+val NumParserInt = NumParser ==> (s => 2 * s.toInt)
NumParser.parse_all("12345")
NumParserInt.parse_all("12345")
@@ -288,7 +288,7 @@
lazy val F: Parser[String, Int] =
("(" ~ E ~ ")") ==> { case ((x, y), z) => y } | NumParserInt
-println(E.parse_all("1+3+4"))
+
println(E.parse_all("4*2+3"))
println(E.parse_all("4*(2+3)"))
println(E.parse_all("(4)*((2+3))"))
@@ -331,7 +331,7 @@
//
// http://www.latkin.org/blog/2017/05/02/when-the-scala-compiler-doesnt-help/
-List(1, 2, 3) contains "your mom"
+List(1, 2, 3).contains("your mom")
// I like best about Scala that it lets me often write
// concise, readable code. And it hooks up with the