marking2/danube.scala
author Christian Urban <urbanc@in.tum.de>
Wed, 30 Oct 2019 14:21:16 +0000
changeset 289 08b5ddbc7e55
parent 284 9a04eb6a2291
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     1
// Part 2 and 3 about Movie Recommendations 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     2
// at Danube.co.uk
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     3
//===========================================
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     4
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     5
import io.Source
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     6
import scala.util._
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     7
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
     8
object CW7b { // for purposes of generating a jar
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
     9
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    10
// (1) Implement the function get_csv_url which takes an url-string
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    11
//     as argument and requests the corresponding file. The two urls
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    12
//     of interest are ratings_url and movies_url, which correspond 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    13
//     to CSV-files.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    14
//     The function should ReTurn the CSV file appropriately broken
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    15
//     up into lines, and the first line should be dropped (that is without
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    16
//     the header of the CSV file). The result is a list of strings (lines
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    17
//     in the file).
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    18
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    19
def get_csv_url(url: String) : List[String] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    20
  val csv = Source.fromURL(url)("ISO-8859-1")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    21
  csv.mkString.split("\n").toList.drop(1)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    22
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    23
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    24
val ratings_url = """https://nms.kcl.ac.uk/christian.urban/ratings.csv"""
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    25
val movies_url = """https://nms.kcl.ac.uk/christian.urban/movies.csv"""
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    26
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    27
// test cases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    28
228
33c2655be47d updated
Christian Urban <urbanc@in.tum.de>
parents: 227
diff changeset
    29
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    30
//val ratings = get_csv_url(ratings_url)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    31
//val movies = get_csv_url(movies_url)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    32
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    33
//ratings.length  // 87313
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    34
//movies.length   // 9742
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    35
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    36
// (2) Implement two functions that process the CSV files. The ratings
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    37
//     function filters out all ratings below 4 and ReTurns a list of 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    38
//     (userID, movieID) pairs. The movies function just ReTurns a list 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    39
//     of (movieId, title) pairs.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    40
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    41
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    42
def process_ratings(lines: List[String]) : List[(String, String)] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    43
  for (cols <- lines.map(_.split(",").toList); 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    44
       if (cols(2).toFloat >= 4)) yield (cols(0), cols(1))  
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    45
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    46
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    47
def process_movies(lines: List[String]) : List[(String, String)] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    48
  for (cols <- lines.map(_.split(",").toList)) yield (cols(0), cols(1))  
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    49
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    50
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    51
// test cases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    52
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    53
//val good_ratings = process_ratings(ratings)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    54
//val movie_names = process_movies(movies)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    55
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    56
//good_ratings.length   //48580
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    57
//movie_names.length    // 9742
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    58
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    59
//==============================================
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    60
// Do not change anything below, unless you want 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    61
// to submit the file for the advanced part 3!
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    62
//==============================================
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    63
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    64
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    65
// (3) Implement a grouping function that calulates a map
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    66
//     containing the userIds and all the corresponding recommendations 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    67
//     (list of movieIds). This  should be implemented in a tail
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    68
//     recursive fashion, using a map m as accumulator. This map
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    69
//     is set to Map() at the beginning of the claculation.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    70
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    71
def groupById(ratings: List[(String, String)], 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    72
              m: Map[String, List[String]]) : Map[String, List[String]] = ratings match {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    73
  case Nil => m
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    74
  case (id, mov) :: rest => {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    75
    val old_ratings = m.getOrElse (id, Nil)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    76
    val new_ratings = m + (id -> (mov :: old_ratings))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    77
    groupById(rest, new_ratings)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    78
  }
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    79
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    80
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    81
// test cases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    82
//val ratings_map = groupById(good_ratings, Map())
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    83
//val movies_map = movie_names.toMap
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    84
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    85
//ratings_map.get("414").get.map(movies_map.get(_)) // most prolific recommender with 1227 positive ratings
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    86
//ratings_map.get("474").get.map(movies_map.get(_)) // second-most prolific recommender with 787 positive ratings
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    87
//ratings_map.get("214").get.map(movies_map.get(_)) // least prolific recommender with only 1 positive rating
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    88
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    89
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    90
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    91
//(4) Implement a function that takes a ratings map and a movie_name as argument.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    92
// The function calculates all suggestions containing
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    93
// the movie mov in its recommendations. It ReTurns a list of all these
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    94
// recommendations (each of them is a list and needs to have mov deleted, 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    95
// otherwise it might happen we recommend the same movie).
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    96
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    97
def favourites(m: Map[String, List[String]], mov: String) : List[List[String]] = 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    98
  (for (id <- m.keys.toList;
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
    99
        if m(id).contains(mov)) yield m(id).filter(_ != mov))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   100
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   101
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   102
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   103
// test cases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   104
// movie ID "912" -> Casablanca (1942)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   105
//          "858" -> Godfather
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   106
//          "260" -> Star Wars: Episode IV - A New Hope (1977)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   107
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   108
//favourites(ratings_map, "912").length  // => 80
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   109
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   110
// That means there are 80 users that recommend the movie with ID 912.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   111
// Of these 80  users, 55 gave a good rating to movie 858 and
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   112
// 52 a good rating to movies 260, 318, 593.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   113
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   114
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   115
// (5) Implement a suggestions function which takes a rating
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   116
// map and a movie_name as arguments. It calculates all the recommended
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   117
// movies sorted according to the most frequently suggested movie(s) first.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   118
def suggestions(recs: Map[String, List[String]], 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   119
                    mov_name: String) : List[String] = {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   120
  val favs = favourites(recs, mov_name).flatten
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   121
  val favs_counted = favs.groupBy(identity).view.mapValues(_.size).toList
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   122
  val favs_sorted = favs_counted.sortBy(_._2).reverse
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   123
  favs_sorted.map(_._1)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   124
}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   125
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   126
// test cases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   127
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   128
//suggestions(ratings_map, "912")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   129
//suggestions(ratings_map, "912").length  
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   130
// => 4110 suggestions with List(858, 260, 318, 593, ...)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   131
//    being the most frequently suggested movies
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   132
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   133
// (6) Implement recommendations functions which generates at most
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   134
// *two* of the most frequently suggested movies. It Returns the 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   135
// actual movie names, not the movieIDs.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   136
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   137
def recommendations(recs: Map[String, List[String]],
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   138
                   movs: Map[String, String],
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   139
                   mov_name: String) : List[String] =
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   140
  suggestions(recs, mov_name).take(2).map(movs.get(_).get)                 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   141
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   142
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   143
// testcases
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   144
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   145
// recommendations(ratings_map, movies_map, "912")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   146
//   => List(Godfather, Star Wars: Episode IV - A NewHope (1977))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   147
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   148
//recommendations(ratings_map, movies_map, "260")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   149
//   => List(Star Wars: Episode V - The Empire Strikes Back (1980), 
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   150
//           Star Wars: Episode VI - Return of the Jedi (1983))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   151
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   152
// recommendations(ratings_map, movies_map, "2")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   153
//   => List(Lion King, Jurassic Park (1993))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   154
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   155
// recommendations(ratings_map, movies_map, "0")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   156
//   => Nil
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   157
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   158
// recommendations(ratings_map, movies_map, "1")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   159
//   => List(Shawshank Redemption, Forrest Gump (1994))
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   160
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   161
// recommendations(ratings_map, movies_map, "4")
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   162
//   => Nil  (there are three ratings fro this movie in ratings.csv but they are not positive)     
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   163
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   164
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   165
// If you want to calculate the recomendations for all movies.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   166
// Will take a few seconds calculation time.
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   167
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   168
//val all = for (name <- movie_names.map(_._1)) yield {
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   169
//  recommendations(ratings_map, movies_map, name)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   170
//}
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   171
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   172
// helper functions
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   173
//List().take(2)
227
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   174
//List(1).take(2)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   175
//List(1,2).take(2)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   176
//List(1,2,3).take(2)
b5f3e814a710 updated
Christian Urban <urbanc@in.tum.de>
parents:
diff changeset
   177
284
9a04eb6a2291 updated
Christian Urban <urbanc@in.tum.de>
parents: 259
diff changeset
   178
}
259
43995ea34fe7 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
   179
43995ea34fe7 updated
Christian Urban <urbanc@in.tum.de>
parents: 228
diff changeset
   180