--- a/marking2/danube_test3.scala Tue Oct 29 23:56:13 2019 +0000
+++ b/marking2/danube_test3.scala Wed Oct 30 11:28:44 2019 +0000
@@ -1,3 +1,5 @@
+import CW7b._
+
// first test
@@ -12,13 +14,13 @@
// second test
def urban_gb(ratings: List[(String, String)]) =
- ratings.groupBy(_._1).mapValues(_.map(_._2).toSet)
+ ratings.groupBy(_._1).view.mapValues(_.map(_._2).toSet).toMap
def urban_gb2(ratings: List[(String, String)]) =
- ratings.groupBy(_._1).mapValues(_.map(_._2))
+ ratings.groupBy(_._1).view.mapValues(_.map(_._2)).toMap
def urban_ck(ratings: List[(String, String)]) =
- urban_gb(ratings) == groupById(ratings, Map()).mapValues(_.toSet)
+ urban_gb(ratings) == groupById(ratings, Map()).view.mapValues(_.toSet).toMap
val ls2_urban = List(("1", "a"), ("1", "b"), ("2", "x"), ("3", "a"), ("2", "y"), ("3", "c"))