View Problem

Fetch an element of a list by index

Given the list [One, Two, Three, Four, Five], fetch the third element ('Three')
DiskEdit
python
list = ['One', 'Two', 'Three', 'Four', 'Five']
list[2]
DiskEdit
clojure
(nth '[One Two Three Four Five] 2)
ExpandDiskEdit
fsharp
let result = List.nth ["One"; "Two"; "Three"; "Four"; "Five"] 2
ExpandDiskEdit
fantom
["One", "Two", "Three", "Four", "Five"][2]
ExpandDiskEdit
fantom
["One", "Two", "Three", "Four", "Five"].get(2)
ExpandDiskEdit
java
String result = list.get(2);
ExpandDiskEdit
erlang
Result = lists:nth(3, List),
ExpandDiskEdit
erlang
Result = element(3, list_to_tuple(List)),
ExpandDiskEdit
erlang
{Left, _} = lists:split(3, List), Result = lists:last(Left),
ExpandDiskEdit
erlang
Result = nth0(2, List),

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