--- a/progs/lecture2.scala Sat Nov 26 19:12:33 2016 +0000
+++ b/progs/lecture2.scala Thu Dec 01 12:19:52 2016 +0000
@@ -180,9 +180,6 @@
-
-
-
def my_flatten(lst: List[Option[Int]]): List[Int] = lst match {
case Nil => Nil
case None::xs => my_flatten(xs)
@@ -200,6 +197,16 @@
get_me_a_string(0)
+// you can also have cases combined
+def season(month: String) = month match {
+ case "March" | "April" | "May" => "It's spring"
+ case "June" | "July" | "August" => "It's summer"
+ case "September" | "October" | "November" => "It's autumn"
+ case "December" | "January" | "February" => "It's winter"
+}
+
+println(season("November"))
+
// User-defined Datatypes
//========================