--- a/progs/lecture1.scala Thu Apr 23 14:49:54 2020 +0100
+++ b/progs/lecture1.scala Wed Aug 12 00:56:20 2020 +0100
@@ -473,6 +473,16 @@
+////////////
+// calculating pi
+def f(n: BigInt) = BigDecimal(4 * n * n) / BigDecimal(4 * n * n - 1)
+
+2 * (BigInt(1) to BigInt(100000)).map(f).product
+
+(1 to 1000).sum
+(1 to 1000).product
+
+
// Further Information
//=====================
@@ -515,6 +525,19 @@
+// declarative
+
+users.filter(_.email.endsWith("@gmail.com"))
+
+// imperative
+
+val result = ListBuffer[User]()
+for(user <- users) {
+ if(user.email.endsWith("@gmail.com")) {
+ result += user
+ }
+}
+result.toList
@@ -522,6 +545,3 @@
-
-
-