View Problem

Remove an element from a list by index

Given the list [Apple, Banana, Carrot], remove the first element to produce the list [Banana, Carrot]
DiskEdit
python
myList = ['Apple', 'Banana', 'Carrot']
print myList
del myList[0]
# or
myList.pop(0) # returns 'Apple'
print myList
DiskEdit
clojure
(let [fruit ["Apple" "Banana" "Carrot"]
index 0]
(concat
(take index fruit)
(drop (+ index 1) fruit)))
DiskEdit
csharp c# 2.0
class Solution1516
{
static void Main()
{
List<string> fruit = new List<string>() { "Apple", "Banana", "Carrot" };
fruit.RemoveAt(0);
}
}
ExpandDiskEdit
erlang
Result = tl(List),
ExpandDiskEdit
erlang
[_|Result] = List,
ExpandDiskEdit
erlang
N = 1, {Left, Right} = lists:split(N - 1, List), Result = Left ++ tl(Right),
ExpandDiskEdit
erlang
Result = drop(1, List),

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