|
local fn = {}
fn.copy = function(t)
local new = {}
for i,v in pairs(t) do new[i] = v end
setmetatable(new,getmetatable(t))
return new
end
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
local fn = {}
fn.shuffle = function(list)
for i = #list, 2, -1 do
local j = math.random(i)
list[i], list[j] = list[j], list[i]
end
end
fn.scramble = function(list)
local new = table.copy(list)
fn.shuffle(new)
return new
end
fn.copy = function(t)
local new = {}
for i,v in pairs(t) do new[i] = v end
setmetatable(new,getmetatable(t))
return new
end
|