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
ruby
['Apple', 'Banana', 'Carrot'].shift
ExpandDiskEdit
ruby
fruit.delete_at(0)
ExpandDiskEdit
cpp C++/CLI .NET 2.0
fruit->RemoveAt(0);
ExpandDiskEdit
fsharp
let split_at list n =
let rec split_at' list' n' left right =
match list' with
| [] -> (List.rev left, List.rev right)
| x :: xs -> if n' <= n then split_at' xs (n' + 1) (x :: left) right else split_at' xs (n' + 1) left (x :: right)
split_at' list 0 [] []

// ------

let (_, right) = split_at fruit 0
ExpandDiskEdit
fsharp
let drop list n =
if n <= 0 then
list
else
let (_, right) = split_at list (n - 1)
right

// ------

let result = (drop fruit 1)
DiskEdit
csharp c# 2.0
class Solution1516
{
static void Main()
{
List<string> fruit = new List<string>() { "Apple", "Banana", "Carrot" };
fruit.RemoveAt(0);
}
}
ExpandDiskEdit
go
offset := 0
list = append(list[:offset], list[offset+1:]...)
ExpandDiskEdit
fantom
list := ["Apple", "Banana", "Carrot"]
list.removeAt(0)

Submit a new solution for ruby, cpp, fsharp, csharp ...
There are 22 other solutions in additional languages (clojure, erlang, groovy, haskell ...)