View Problem

Join the elements of a list, separated by commas

Given the list [Apple, Banana, Carrot] produce "Apple, Banana, Carrot"
ExpandDiskEdit
scala
val result =
((fruit.tail foldLeft (new StringBuilder(fruit.head))) {(acc, e) => acc.append(", ").append(e)}).toString
ExpandDiskEdit
scala
val result = fruit.mkString(",")
ExpandDiskEdit
scala 2.9.0.1
val fruit = List[String]("Apple", "Banana", "Carrot")
println(fruit.mkString(", "))

Submit a new solution for scala
There are 26 other solutions in additional languages (clojure, cpp, csharp, erlang ...)