View Problem

Join the elements of a list, separated by commas

Given the list [Apple, Banana, Carrot] produce "Apple, Banana, Carrot"
ExpandDiskEdit
fantom
["Apple", "Banana", "Carrot"].join(", ")
ExpandDiskEdit
erlang
Result = string:join(Fruit, ", "),
ExpandDiskEdit
erlang
Result = lists:foldl(fun (E, Acc) -> Acc ++ ", " ++ E end, hd(Fruit), tl(Fruit)),
ExpandDiskEdit
erlang
Result = lists:flatten([ hd(Fruit) | [ ", " ++ X || X <- tl(Fruit)]]).
ExpandDiskEdit
fsharp
let result = String.Join(", ", [|"Apple"; "Banana"; "Carrot"|])
ExpandDiskEdit
fsharp
let result = (List.fold_left (fun acc item -> acc ^ (", " ^ item)) (List.hd fruit) (List.tl fruit))
ExpandDiskEdit
fsharp
let result = (List.fold_left (fun (acc : StringBuilder) (item : string) -> acc.Append(", ").Append(item)) (new StringBuilder(List.hd fruit)) (List.tl fruit)).ToString()
DiskEdit
clojure
(apply str (interpose ", " '("Apple" "Banana" "Carrot")))

Submit a new solution for fantom, erlang, fsharp, or clojure
There are 21 other solutions in additional languages (cpp, csharp, go, groovy ...)