progs/lecture1.scala
changeset 329 8a34b2ebc8cc
parent 316 8b57dd326a91
child 335 7e00d2b13b04
--- a/progs/lecture1.scala	Tue Dec 03 11:07:09 2019 +0000
+++ b/progs/lecture1.scala	Mon Jan 27 10:18:13 2020 +0000
@@ -425,7 +425,17 @@
 // - no vars, no ++i, no +=
 // - no mutable data-structures (no Arrays, no ListBuffers)
 
-// But what the heck....
+// But what the heck....lets try to count to 1 Mio in parallel
+
+var cnt = 0
+
+for(i <- (1 to 1000000).par) cnt += 1
+
+println(s"Should be 1 Mio: $cnt")
+
+
+
+// Or
 // Q: Count how many elements are in the intersections of 
 //    two sets?
 // A; IMPROPER WAY (mutable counter)