title: List concatenation operations in Scala
body: <p>In Scala, there are two operations available for List creation from other List objects:conc(:::) and cons(::)</p>
  
  <p>::: flattens the elements from input lists.</p>
  
  <pre><code>val fruits = List("Mango","Apple","Grapes");
  val veggies = List("Potato","Brinjal","Jackfruit")
  val conc = fruits:::veggies
  </code></pre>
  
  <p>conc is List("Mango","Apple","Grapes","Potato","Brinjal","Jackfruit").
  As original lists are immutable, doesn't it mean now we have duplicated data?</p>
  
  <p>in case of ::, this happens:</p>
  
  <pre><code>val fruits = List("Mango","Apple","Grapes");
  val veggies = List("Potato","Brinjal","Jackfruit")
  val cons = fruits::veggies
  </code></pre>
  
  <p>cons is List(List("Mango","Apple","Grapes"),"Potato","Brinjal","Jackfruit")
  It seems first element in cons is merely reference to fruits, hence negligible duplication.But last three entries are again major duplication from veggies.</p>