Login
|
Signup
langref.org
-
python
,
clojure
,
fsharp
, and
fantom
add..
all
cpp
csharp
erlang
go
groovy
haskell
java
ocaml
perl
php
ruby
scala
Home
All
Solved
Unsolved
Strings
Numbers
Regex
Lists
Maps
Structure
Files
Dates
OOP
Networking
XML
Algorithms
Misc
Parallel
View Problem
Lists
Access
Fetch an element of a list by index
Given the list
[One, Two, Three, Four, Five]
, fetch the third element (
'Three'
)
python
list = ['One', 'Two', 'Three', 'Four', 'Five']
list[2]
list = ['One', 'Two', 'Three', 'Four', 'Five']
list[2]
clojure
(nth '[One Two Three Four Five] 2)
(nth '[One Two Three Four Five] 2)
fsharp
let result = List.nth ["One"; "Two"; "Three"; "Four"; "Five"] 2
#light
open System
let result = List.nth ["One"; "Two"; "Three"; "Four"; "Five"] 2
printfn "%s" result
fantom
["One", "Two", "Three", "Four", "Five"][2]
class SolutionXX
{
Void main()
{
["One", "Two", "Three", "Four", "Five"][2]
}
}
fantom
["One", "Two", "Three", "Four", "Five"].get(2)
class SolutionXX
{
Void main()
{
["One", "Two", "Three", "Four", "Five"].get(2)
}
}
Submit a new solution for
python
,
clojure
,
fsharp
, or
fantom
There are 20 other solutions in
additional
languages (
cpp
,
csharp
,
erlang
,
go
...)