--- a/progs/lecture2.scala Thu Nov 17 11:17:04 2016 +0000
+++ b/progs/lecture2.scala Thu Nov 17 11:24:45 2016 +0000
@@ -14,6 +14,17 @@
List(7,2,3,4,5,6).find(_ < 4)
List(5,6,7,8,9).find(_ < 4)
+
+// Values in types
+//
+// Boolean:
+// Int:
+// String:
+//
+// Option[String]:
+//
+
+
val lst = List(None, Some(1), Some(2), None, Some(3))
lst.flatten
@@ -37,7 +48,7 @@
-// error handling with option (no exceptions)
+// error handling with Option (no exceptions)
//
// Try(something).getOrElse(what_to_do_in_an_exception)
//
@@ -75,6 +86,14 @@
+// even Scala is not immune to problems like this:
+
+List(5,6,7,8,9).indexOf(7)
+
+
+
+
+
// Type abbreviations
//====================
@@ -299,8 +318,8 @@
sum_squares(lst)
sum_cubes(lst)
-def fact(n: Int): Int =
- if (n == 0) 1 else n * fact(n - 1)
+// lets try it factorial
+def fact(n: Int): Int = ...
def sum_fact(lst: List[Int]) = sumOf(fact, lst)
sum_fact(lst)