View Problem

Rotate a list

Given a list ["apple", "orange", "grapes", "bananas"], rotate it by removing the first item and placing it on the end to yield ["orange", "grapes", "bananas", "apple"]
DiskEdit
ruby
items = ["apple", "orange", "grapes", "bananas"]
items << first = items.shift

# items is rotated
# first contains the first value in the list
ExpandDiskEdit
erlang
N = 1, {Left, Right} = lists:split(N, List), Result = Right ++ Left,
ExpandDiskEdit
erlang
N = 1, Result = rotate(N, List),
ExpandDiskEdit
csharp 2.0 (LinkedList), 3.0 ("var" keyword)
var lst = new LinkedList<String>(new String[] {"apple", "orange", "grapes", "banana"});
lst.AddLast(lst.First());
lst.DeleteFirst();
ExpandDiskEdit
cpp C++/CLI .NET 2.0
fruit->Add(fruit[0]); fruit->RemoveAt(0);
ExpandDiskEdit
cpp
rotate(fruit.begin(), fruit.begin()+1, fruit.end());
DiskEdit
clojure
(let [fruit ["apple" "orange" "grapes" "bananas"]]
(concat (rest fruit) [(first fruit)])

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