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