scala> // apply() can be used to select an element in List scala> // Beware : Takes time proportion to the index #351 scala> val data = List("a", "b", "c", "d", "e", "f") data: List[String] = List(a, b, c, d, e, f) scala> val res = data.apply(2) res: String = c scala> val res = data(2) res: String = c scala> scala> // indices : Returns indices of a list scala> val data = List("a", "b", "c", "d", "e", "f") data: List[String] = List(a, b, c, d, e, f) scala> val res = data.indices res: scala.collection.immutable.Range = Range(0, 1, 2, 3, 4, 5) scala> scala> // flatten : Flatten multiple lists into a single list scala> val data = List(List(1, 2, 3), List(4, 5), List(6, 7)) data: List[List[Int]] = List(List(1, 2, 3), List(4, 5), List(6, 7)) scala> val res = data.flatten res: List[Int] = List(1, 2, 3, 4, 5, 6, 7) scala> scala> // zip, zipWithIndex #352 scala> val d1 = List("a", "b", "c", "d", "e", "f") d1: List[String] = List(a, b, c, d, e, f) scala> val d2 = List(1, 2, 3) d2: List[Int] = List(1, 2, 3) scala> val res = d1.zip(d2) res: List[(String, Int)] = List((a,1), (b,2), (c,3)) scala> val res = d1.indices.zip(d1) res: scala.collection.immutable.IndexedSeq[(Int, String)] = Vector((0,a), (1,b), (2,c), (3,d), (4,e), (5,f)) scala> val res = d1.zipWithIndex res: List[(String, Int)] = List((a,0), (b,1), (c,2), (d,3), (e,4), (f,5)) scala> scala> // unzip scala> val d1 = List("a", "b", "c", "d", "e", "f") d1: List[String] = List(a, b, c, d, e, f) scala> val zipped = d1.zipWithIndex zipped: List[(String, Int)] = List((a,0), (b,1), (c,2), (d,3), (e,4), (f,5)) scala> val unzipped = zipped.unzip unzipped: (List[String], List[Int]) = (List(a, b, c, d, e, f),List(0, 1, 2, 3, 4, 5))