View Problem

Remove the last element of a list

ExpandDiskEdit
php
$list = array("Apple", "Banana", "Carrot");
unset($list[count($list)-1]);

// Be aware of that
// $list[] = "Orange";
// will be $list[3] and not $list[2]
ExpandDiskEdit
php
$list = array("Apple", "Banana", "Carrot");
array_pop($list);
ExpandDiskEdit
erlang
Result = init(List),
ExpandDiskEdit
erlang
Result = take(length(List) - 1, List),
ExpandDiskEdit
erlang
Result = lists:reverse(tl(lists:reverse(List))),
DiskEdit
csharp
List<string> fruits = new List() { "apple", "banana", "cherry" };
fruits.RemoveAt(fruits.Length - 1);

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