// First order Methods do not take function as arguments #345 scala> /////////////////////////////////////////////////////////// scala> // Concatenating Multiple List using ::: #345 scala> /////////////////////////////////////////////////////////// scala> val l1 = List(1, 2, 3) l1: List[Int] = List(1, 2, 3) scala> val l2 = List(4, 5) l2: List[Int] = List(4, 5) scala> val l3 = l1 ::: l2 l3: List[Int] = List(1, 2, 3, 4, 5) scala> scala> /////////////////////////////////////////////////////////// scala> // length scala> // Is an expensive operation scala> // ***Need to traverse the whole list to find the scala> // length #347 scala> // Use xs.isEmpty if possible scala> /////////////////////////////////////////////////////////// scala> val l1 = List(1, 2, 3) l1: List[Int] = List(1, 2, 3) scala> l1.length res1: Int = 3 scala> scala> /////////////////////////////////////////////////////////// scala> // init & last scala> // *** Need to traverse the whole list to get scala> // init & last scala> // Best Practice : Organize the list to use scala> // head & tail instead scala> /////////////////////////////////////////////////////////// scala> val l1 = List(1, 2, 3, 4, 5, 6) l1: List[Int] = List(1, 2, 3, 4, 5, 6) scala> val l2 = l1.init l2: List[Int] = List(1, 2, 3, 4, 5) scala> val l3 = l1.last l3: Int = 6