본문으로 이동

모듈:table/reverse

위키낱말사전, 말과 글의 누리

이 모듈에 대한 설명문서는 모듈:table/reverse/설명문서에서 만들 수 있습니다

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