Logo

Programming-Idioms

History of Idiom 19 > diff from v19 to v20

Edit summary for version 20 by :
New Lua implementation by user [jparoz]

Version 19

2015-11-30, 12:37:26

Version 20

2016-02-16, 15:53:56

Idiom #19 Reverse a list

Reverse the order of the elements of list x .
This may reverse "in-place" and destroy the original ordering.

Idiom #19 Reverse a list

Reverse the order of the elements of list x .
This may reverse "in-place" and destroy the original ordering.

Code
rev = {}
for i=#x, 1, -1 do
	rev[#rev+1] = x[i]
end