progs/lecture1.scala
changeset 273 b19227660752
parent 272 da3d30ae67ec
child 308 e86add5a6961
--- a/progs/lecture1.scala	Wed Aug 07 14:32:21 2019 +0100
+++ b/progs/lecture1.scala	Wed Aug 07 16:15:42 2019 +0100
@@ -472,6 +472,16 @@
 time_needed(10, for (n <- list) yield n + 42)
 time_needed(10, for (n <- list.par) yield n + 42)
 
+val list = (1 to 1000000).toList.map(BigInt(_))
+list.sum
+list.par.sum
+list.par.reduce(_ + _)
+list.par.aggregate(BigInt(0))(_ + _, _ + _)
+
+time_needed(10, list.sum)
+time_needed(10, list.par.sum)
+time_needed(10, list.par.reduce(_ + _))
+time_needed(10, list.par.aggregate(BigInt(0))(_ + _, _ + _))
 
 
 // Just for "Fun": Mutable vs Immutable