# 19
Implementation
Perl

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import java.util.List;
static <T> void reverse(List<T> x){
int n = x.size();
for(int i=0;i<n/2;i++){
T tmp = x.get(i);
x.set(i, x.get(n-i-1));
x.set(n-i-1, tmp);
}
}
x.reverse!
x = reversed(x)
import std.algorithm;
reverse(x);
for i, j := 0, len(x)-1; i < j; i, j = i+1, j-1 {
x[i], x[j] = x[j], x[i]
}
import java.util.Collections;
Collections.reverse(x);
\$x = array_reverse(\$x, true);
x = x.reverse();
let y: Vec<_> = x.iter().rev().collect();
import std.range;
auto y = x.retro;
x.reversed.toList()
var n,i: integer;
[...]
n:= length(x);
setlength(x, n+1);
for i := 0 to (n div 2)-1 do
begin
x[n] := x[i];
x[i] := x[n-i-1];
x[n-i-1] := x[n];
end;
setlength(x, n);
var n,i: integer;
tmp:TElement;
[...]
n:= length(x);
for i := 0 to (n div 2)-1 do
begin
tmp := x[i];
x[i] := x[n-i-1];
x[n-i-1] := tmp;
end;
reverse x
lists:reverse(List)
(reverse x)
Enum.reverse(x)
rev = {}
for i=#x, 1, -1 do
rev[#rev+1] = x[i]
end

-- in-situ reversal
function reverse(t)
local n = #t
local i = 1
while i < n do
t[i],t[n] = t[n],t[i]
i = i + 1
n = n - 1
end
end
System.Collections.Generic;
x.Reverse();
#include <algorithm>
std::reverse(begin(x), end(x));
val items = List(1, 2, 3, 4, 5)
items.reverse
X.Reverse_Elements;
x = x[::-1]
int *p1 = x;
int *p2 = x + N-1;

while (p1 < p2)
{
int temp = *p1;
*(p1++) = *p2;
*(p2--) = temp;
}
(reverse x)
list = [1, 2, 3, 4, 5]
Enum.reverse(list)
(reverse x)
x.reverse();