View Problem

Define a static list

Define the list [One, Two, Three, Four, Five]
DiskEdit
clojure
(def a '[One Two Three Four Five])
DiskEdit
clojure
(def a (list "One" "Two" "Three" "Four" "Five"))
ExpandDiskEdit
cpp C++/CLI .NET 2.0
array<String^>^ input = {"One", "Two", "Three", "Four", "Five"};
Generic::List<String^>^ list = gcnew Generic::List<String^>((Generic::IEnumerable<String^>^) input);
ExpandDiskEdit
cpp C++/CLI .NET 2.0
Generic::List<String^>^ list = gcnew Generic::List<String^>();

list->Add("One");
list->Add("Two");
list->Add("Three");
list->Add("Four");
list->Add("Five");
ExpandDiskEdit
cpp
std::string input[] = {"One", "Two", "Three", "Four", "Five"};
std::list<std::string> list(input, input + 5);
ExpandDiskEdit
cpp
std::list<std::string> list;

list.push_back("One");
list.push_back("Two");
list.push_back("Three");
list.push_back("Four");
list.push_back("Five");
ExpandDiskEdit
cpp C++0x/C++11
list<string> lst = { "One", "Two", "Three", "Four", "Five" };
ExpandDiskEdit
cpp boost
list<string> lst;
lst += "One", "Two", "Three", "Four", "Five";
ExpandDiskEdit
erlang
List = [one, two, three, four, five],
ExpandDiskEdit
erlang
List = ['One', 'Two', 'Three', 'Four', 'Five'],
ExpandDiskEdit
fantom
list := ["One", "Two", "Three", "Four", "Five"]
ExpandDiskEdit
fsharp
let list = ["One"; "Two"; "Three"; "Four"; "Five"]
ExpandDiskEdit
fsharp
let list = (new Generic.LinkedList<string>([|"One"; "Two"; "Three"; "Four"; "Five"|]))
ExpandDiskEdit
fsharp
let list = (new Generic.LinkedList<string>())

list.AddFirst("One") ; list.AddLast("Five") ; list.AddBefore(list.Find("Five"), "Four")
list.AddAfter(list.Find("One"), "Two") ; list.AddAfter(list.Find("Two"), "Three")
ExpandDiskEdit
fsharp
let list = (new Generic.List<string>())

[|"One"; "Two"; "Three"; "Four"; "Five"|] |> Array.iter (fun x -> list.Add(x))
DiskEdit
groovy
list = ['One', 'Two', 'Three', 'Four', 'Five']
DiskEdit
groovy
// other variations
List<String> numbers1 = ['One', 'Two', 'Three', 'Four', 'Five']
String[] numbers2 = ['One', 'Two', 'Three', 'Four', 'Five']
numbers3 = new LinkedList(['One', 'Two', 'Three', 'Four', 'Five'])
numbers4 = ['One', 'Two', 'Three', 'Four', 'Five'] as Stack // Groovy 1.6+
DiskEdit
haskell
let a = ["One", "Two", "Three", "Four", "Five"]
ExpandDiskEdit
java
List<String> numbers = new ArrayList<String>();
Collections.addAll(numbers, "One", "Two", "Three", "Four", "Five");
ExpandDiskEdit
java
List numbers = new ArrayList();
numbers.add("One");
numbers.add("Two");
numbers.add("Three");
numbers.add("Four");
numbers.add("Five");
ExpandDiskEdit
java
List numbers = Arrays.asList(new String[]{"One", "Two", "Three", "Four", "Five"});
ExpandDiskEdit
java
String[] numbers = {"One", "Two", "Three", "Four", "Five"};
ExpandDiskEdit
java
List numbers = new ArrayList(){{put("One"); put("Two"); put("Three"); put("Four"); put("Five"); }};
DiskEdit
ocaml
let list = [ "One"; "Two"; "Three"; "Four"; "Five" ];;
DiskEdit
perl
@list = qw(One Two Three Four Five);
DiskEdit
perl
@list = ('One', 'Two', 'Three', 'Four', 'Five');
ExpandDiskEdit
php
$list = array("One", "Two", "Three", "Four", "Five");
ExpandDiskEdit
php
$list = array();
$list[] = "One";
$list[] = "Two";
$list[] = "Three";
$list[] = "Four";
$list[] = "Five";
DiskEdit
php 5.3.0
<?php
$list = new SplFixedArray(5);

$list[0] = "One";
$list[1] = "Two";
$list[2] = "Three";
$list[3] = "Four";
$list[4] = "Five";
?>
DiskEdit
python
list = ['One', 'Two', 'Three', 'Four', 'Five']
print list
ExpandDiskEdit
ruby
list = ['One', 'Two', 'Three', 'Four', 'Five']
ExpandDiskEdit
ruby
list = %w(One Two Three Four Five)
ExpandDiskEdit
scala
val list = "One" :: "Two" :: "Three" :: "Four" :: "Five" :: Nil
ExpandDiskEdit
scala
val list = List("One", "Two", "Three", "Four", "Five")
ExpandDiskEdit
scala
val list: List[String] = List("One", "Two", "Three", "Four", "Five")

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