Jump to content

Module:table/reverse

Wiktionary වෙතින්


local table_length_module = "Module:table/length"

local function table_len(...)
	table_len = require(table_length_module)
	return table_len(...)
end

--[==[
Takes a list, and returns a new list with the values in the reverse order: { { "a", "b", "c" }} -> { { "c", "b", "a" }}.]==]
return function(t)
	local list, t_len = {}, table_len(t)
	for i = 1, t_len do
		list[i] = t[t_len - i + 1]
	end
	return list
end
"https://si.wiktionary.org/w/index.php?title=Module:table/reverse&oldid=221484" වෙතින් සම්ප්‍රවේශනය කෙරිණි